Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hello,
I am new in Excel object model. I am writing VBScript to open Excel file. The following is a segment of my codes: Set objExcelApp = CreateObject("Excel.Application") 'Open Excel file Set objExcelWorkbook = objExcelApp.Workbooks.Open(pstrExcelFilename) ' If IsNull (objExcelWorkbook) Then objExcelApp.Quit Set objExcelWorkbook = Nothing Set objExcelApp = Nothing vfValidateABRUploadExcel = cintErrorOpenExcelFile Exit Function End If 'Set the active worksheet Set objExcelWorksheet = objExcelWorkbook.Sheets(cintExcelWorkSheetNo) objExcelWorksheet.Activate If the Excel file is invalid format (even file extension is XLS), it will throw exception at the "objExcelApp.Workbooks.Open(pstrExcelFilename) " statement (that is, the program cannot run to "IsNull (objExcelWorkbook)" line). May I know how to prevent open invalid format Excel file? Or, how do I catch the exception that throws at "objExcelApp.Workbooks.Open(pstrExcelFilename) " statement? Thanks a lot. Sa |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
How do I prevent Excel trying to open a non-existing file at start | Excel Discussion (Misc queries) | |||
Prevent reviewing toolbar from coming up when I open a file? | Excel Discussion (Misc queries) | |||
cannot open excel file - says invalid file format - what to do? | Excel Discussion (Misc queries) | |||
Prevent Access To already open file | New Users to Excel | |||
How to prevent my Macro from opening up another Excel App when I open any other excel file | Excel Programming |