0

I am getting exception when

:m_xExcel>>Workbooks>>Open(sBinder,Ulnk,RdOnly,Fmt,Pwd,Pwd)

is getting executed. Below is the code and exception. How to avoid this exception? i am using office 16 in my system.

Code

WHEN EXCEPTION IN
    //open the requested workbook
    IF Pwd="" THEN
        ........
                ........``

    OTHERWISE
        ECRIRE_TRACE("if password is not empty:" +Pwd)
        :m_xExcel>>Workbooks>>Open(sBinder,Ulnk,RdOnly,Fmt,Pwd,Pwd)
        IF SheetPwd>"" THEN
            ECRIRE_TRACE("Unprotected")
            :m_xExcel>>ActiveSheet>>Unprotect(SheetPwd)
        OTHERWISE
            ECRIRE_TRACE("Unprotected - else")
            :m_xExcel>>ActiveSheet>>Unprotect 
        END
    END
DO
    :m_sErreur=ExceptionInfo()
    :MsgError("Unable to open workbook.",ExceptionInfo())
    ExceptionActive()   
    RETURN
END

Exception

Unable to open workbook.
You called the Automation method 'Open'.
While attempting to invoke the method <Open> or read the property<Open>, the Automation/ActiveX object returned the following error:
'Erreur 800A03EC : Microsoft Excel cannot access the file 'D:\WebDev\DATA\Car_Reporting_Data\MTO BASE EURO.xls'. There are several possible reasons:

• The file name or path does not exist.
• The file is being used by another program.
• The workbook you are trying to save has the same name as a currently open workbook.'

I tried to change the office version. But didn't work.

James Z
  • 12,209
  • 10
  • 24
  • 44
  • It is not clear, but you are using Exception but you should also add Error. case Exception and case Error – toto Apr 20 '23 at 16:18

0 Answers0