View Single Post
  #1   Report Post  
Posted to microsoft.public.excel.misc
Trefor Trefor is offline
external usenet poster
 
Posts: 201
Default Run-time Error '5' - Invalid procedure call or argument


I am not sure what is going on here and am interested in any feedback I can
get please.

I am using some code to open an excel workbook that is password protected. I
also use code to save the file with the password.

On one particular file I am getting this run-time error in the following code:

DataFile = Application.GetOpenFilename("Data Collect Automation - Data
Files (*.DCA), *.DCA", , "Data Collect Automation - Data Files")
If DataFile < "" And DataFile < "False" Then
On Error Resume Next
Workbooks.Open DataFile, 0, False, , Password:="mypassword"
<--error
here

Two things have me beat, why does this not get trapped in the error trap?

Secondly, the file does get opened so the password must be correct, I tried
opening the same file the same way but without a password and I get an error
1004 and it gets trapped ok. So if the file gets opened as normal (although
the code crashes), what is the error actually referring to? It can't be the
code because it works fine on all the other files and has been working fine
for years.

I have an import routine routine so I imported all the data from the old
file to a new fiile, saved it and re-opened without any code change and it
works fine. So it must be related to this particualar file. I didn't want to
waste to much time finding out why it occured, but without an error trap to
handle it I am forced to fix one or the other.

Anyone?

--
Trefor