Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA open workbook xlxs in 2003 that contains a password

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
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
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default VBA open workbook xlxs in 2003 that contains a password

On 16 Oct, 14:01, Dave Peterson wrote:
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- Hide quoted text -

- Show quoted text -


Hi Dave,

Thanks for your quick response. The problem I'm getting is that
because I'm in 2003 and the file is xlxs then the password prompt is
coming up and I can 't move on without pressing return.

Cheers

Mac
  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default VBA open workbook xlxs in 2003 that contains a password

Even with the "on error" stuff?

If that's true, then I don't have a suggestion. (I don't use the compatibility
pack.)

Sorry.

wrote:
<<snipped
Hi Dave,

Thanks for your quick response. The problem I'm getting is that
because I'm in 2003 and the file is xlxs then the password prompt is
coming up and I can 't move on without pressing return.

Cheers

Mac


--

Dave Peterson
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 19
Default VBA open workbook xlxs in 2003 that contains a password

A shot in the dark, because "On Error.." should cure it, addition to Dave's
code:
dim wkbk as workbook
.....
Application.DisplayAlerts=False
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
Application.DisplayAlerts=True

Regards,
The Code Cage Team
www.thecodecage.com/forumz

"Dave Peterson" wrote:

Even with the "on error" stuff?

If that's true, then I don't have a suggestion. (I don't use the compatibility
pack.)

Sorry.

wrote:
<<snipped
Hi Dave,

Thanks for your quick response. The problem I'm getting is that
because I'm in 2003 and the file is xlxs then the password prompt is
coming up and I can 't move on without pressing return.

Cheers

Mac


--

Dave Peterson

Reply
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
I know my password, yet it will not open my workbook GIB Excel Worksheet Functions 1 March 25th 09 06:23 PM
Open Workbook - Password J.W. Aldridge Excel Programming 3 October 12th 07 01:53 AM
Open workbook with password. J.W. Aldridge Excel Programming 0 October 10th 07 12:00 AM
Open workbook with password in VBA Shawn G. Excel Programming 2 November 15th 06 03:58 PM
Open a password protected excel workbook from second workbook to fetch data using dynamic connection kaustav choudhury Excel Programming 2 April 3rd 04 06:18 AM


All times are GMT +1. The time now is 03:18 PM.

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

About Us

"It's about Microsoft Excel"