View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Dave Peterson Dave Peterson is offline
external usenet poster
 
Posts: 35,218
Default VBA open workbook xlxs in 2003 that contains a password

dim wkbk as workbook
....

set wkbk = nothing
on error resume next
set wkbk = workbooks.open(filename:=file, ..., password:="IncorrectPassword")
on error goto 0

if wkbk is nothing then
'workbook didn't open
else
'do the real work
end if

===
Personally, I find using the keyword parms makes the code much easier to
understand.

wrote:

Hi,

I have a folder a 5 files (one of them has a password to open it).
They are all xlxs and I am working on 2003 with the file convertor
installed.

I have the following vba workbooks.open(file, false, true,
"IncorrectPassword")

What I would like to do is if I come to the file with the password not
open it and just move on.

Instead I keep getting the password open display and I don't want to
have to click out of it.

Any help much appreciated.

Mac


--

Dave Peterson