LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.misc
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
 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
to call procedure in a worksheet in a module CAPTGNVR Excel Discussion (Misc queries) 4 January 30th 07 09:39 PM
Compile Error Argument Not optional [email protected] Excel Discussion (Misc queries) 1 August 16th 06 04:58 PM
Run-time error '5': Invalid Procedure Call or Argument Nikila Excel Discussion (Misc queries) 2 February 24th 06 09:26 PM
simplify procedure to get rid of 0 error values in a spreadsheet Frederic Excel Worksheet Functions 1 February 8th 06 04:47 AM
VBA Compile error: Procedure too large? Jerry Dyben Excel Discussion (Misc queries) 1 October 31st 05 10:15 PM


All times are GMT +1. The time now is 06:59 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"