ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Open a Workbook (https://www.excelbanter.com/excel-programming/322807-open-workbook.html)

papamobil68

Open a Workbook
 
Hi

I use excel in automation from a 3rd pary application.
This works ok, but is not robust enough if something is wrong with the file.
....
xlWorkBook := xlApp.Workbooks.Open(_FilenameAndPath)
...
Since in my 3rd party application I cannot use VBA, there nothing like 'On
Error goto...' Of course, I can check the existence of the file, but format
can still be wrong.


Any ideas to make this code more reliable?
Thank you in advance.
P



Markus Scheible[_2_]

Open a Workbook
 
Hi unknown,

xlWorkBook := xlApp.Workbooks.Open(_FilenameAndPath)


Well, you could at least use a

If IsError(Workbooks.Open(FileName:="abcd.xls")) = True
Then

Else
End If

to catch the error of not having the file...


the file, but format
can still be wrong.


How do you mean that?

Best

Markus



Tom Ogilvy

Open a Workbook
 
You are asking a question about the capabilities or programming approach for
an unnamed 3rd party application/programming language. Perhaps you should
consult the manufacturer/author.

Excel doesn't have a parameter in the open command that specifies to ignore
errors when opening.

--
Regards,
Tom Ogilvy



"papamobil68" wrote in message
...
Hi

I use excel in automation from a 3rd pary application.
This works ok, but is not robust enough if something is wrong with the

file.
...
xlWorkBook := xlApp.Workbooks.Open(_FilenameAndPath)
..
Since in my 3rd party application I cannot use VBA, there nothing like 'On
Error goto...' Of course, I can check the existence of the file, but

format
can still be wrong.


Any ideas to make this code more reliable?
Thank you in advance.
P






All times are GMT +1. The time now is 02:08 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com