Open a Workbook

  • Thread starter Thread starter papamobil68
  • Start date Start date
P

papamobil68

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
 
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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top