Error 13 in 'WorkBooks.open'

Z

Zayas

I distribute by Internet a free program and sometimes it happens the
strange error that I describe:

I have an Excel workbook and one of the macros open another workbook.
I do not know why, when the macro open the second workbook, some
times, occurs an "error 13".
Somebody has idea that it can happen?

Dim FileToOpen1 As String
FileToOpen1 = "C:\Files\ExcelData.xls"
Workbooks.Open Filename:=FileToOpen1


Thanks in advance.

Zayas
 
P

Peter T

#13 is a type mismatch error, I doubt directly raised on the Workbooks.Open
line but somewhere else. If you haven't included an error handler normally
the code will break on the problematic code line.

Regards,
Peter T
 
Z

Zayas

#13 is a type mismatch error, I doubt directly raised on the Workbooks.Open
line but somewhere else. If you haven't included an error handler normally
the code will break on the problematic code line.

Regards,
Peter T










- Mostrar texto de la cita -

I have an error handler. It seems incredible but it gives error 13
(type mismatch) in the 'Workbooks.Open Filename:=FileToOpen1' line.
 
C

Chip Pearson

If you have error handling set to "Trap Unhandled Errors" (in VBA,
Tools menu, Options item, General tab) and an error occurs in an
object module (a Class, UserForm, or Sheet or ThisWorkbook module),
VBA marks the line that called the object module as being in error,
even though the actual error occurred in the object module. For
example, if you have code in Class1 that causes an error, the code in
a standard module that called the code in Class1 will be marked as the
error. This can mask the true source of the error.

You should always run your code with the "Break In Class Module"
option in effect. This causes VBA to show the error in the object
module, where it really occurred, rather than in the calling code.

Cordially,
Chip Pearson
Microsoft MVP
Excel Product Group
Pearson Software Consulting, LLC
www.cpearson.com
(email on web site)
 
Z

Zayas

If you have error handling set to "Trap Unhandled Errors" (in VBA,
Tools menu, Options item, General tab) and an error occurs in an
object module (a Class, UserForm, or Sheet  or ThisWorkbook module),
VBA marks the line that called the object module as being in error,
even though the actual error occurred in the object module. For
example, if you have code in Class1 that causes an error, the code in
a standard module that called the code in Class1 will be marked as the
error. This can mask the true source of the error.

You should always run your code with the "Break In Class Module"
option in effect. This causes VBA to show the error in the object
module, where it really occurred, rather than in the calling code.

Cordially,
Chip Pearson
Microsoft MVP
    Excel Product Group
Pearson Software Consulting, LLCwww.cpearson.com
(email on web site)




- Mostrar texto de la cita -


Thank you very much, I will do it.

Zayas
 

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

Top