Open Password protected workbook via VBA in another workbook

janegrace

New Member
Joined
Jan 12, 2003
Messages
23
I'm using one workbook (A) to contain VBA which needs to open another workbook (B). The workbook B has a password (to modify -- the password was applied via SAVE AS, TOOLS, GENERAL OPTIONS, Password to Modify) I can't seem to get the syntax right in the VBA to open workbook B by supplying the password as part of the WORKBOOKS.Open Filename:="C:\thatfile.xls" statement.
 

Excel Facts

Last used cell?
Press Ctrl+End to move to what Excel thinks is the last used cell.
What that causes to happen is I get the prompt box where I can choose to enter the password, or choose 'readonly.' And actually, as I did that, I realized that what I really want is for the VBA to open the file READONLY -- I don't want the password to be used. SO I asked the question backwards. GOod thing newbies are your favorite (your favorite what -- dinner? Hmm, braised newbies with raisin sauce....Hmmmm) By the way, I have
Application.DisplayAlerts = False
Application.ScreenUpdating = False
Thank you for your quick response! JG
 
Upvote 0
janegrace said:
GOod thing newbies are your favorite (your favorite what -- dinner? Hmm, braised newbies with raisin sauce....Hmmmm)

Too funny! Here's what you need instead:

Workbooks.Open Filename:="C:\Hello.xls", ReadOnly:= True
 
Upvote 0

Forum statistics

Threads
1,214,543
Messages
6,120,123
Members
448,947
Latest member
test111

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top