Automatically Open WB Read Only and Not Show Dialog Box

prabby25101981

Active Member
Joined
Jul 28, 2010
Messages
348
Hi Guys,

I have a workbook, which is protected with password to open using Save As -> Tools -> General Options. I am trying to open this workbook through a code in another, but it asks for the password to open.

Can someone let me know the code to bypass this dialog box (at open) and automatically open the file Read Only?

I hope I explained it well enough.

Thanks!
 

Excel Facts

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.
Try this...

Code:
[COLOR=magenta]Sub[/COLOR] OpenWb_RO()
    [COLOR=magenta]Set[/COLOR] MyWb = Workbooks.Open("ProtectedWorkbook.xls", , [COLOR=magenta]True[/COLOR], , "Password")
[COLOR=magenta]End Sub[/COLOR]
where TRUE refers to the boolean to open the workbook as ReadOnly:
 
Upvote 0
Hi GWteB,

Thanks for the reply. I have already tried that, but that does not serve the purpose as the dialog box still appears when the workbook is called.

Thanks!
 
Upvote 0
I have no explanation for that behaviour, it should work (at least it does for me). Perhaps an other workaround is needed, I am just thinking out loud:

Write some appropriate code:
For the protected workbook (so the "child", saved as an add-in so sheets will not be visible, however without the open-protection you wishes to use):
- wb_open_event that checks the existance of a certain file;
- ..... file exists --> proceed and turn the addin into a "normal" workbook;
- ..... if not --> force a "silent" wb_close.
- wb_beforesave_event to turn the workbook back into an addin for the next time.

For the "parent" :
- as a matter of course, make sure the expected file exists before opening the "child".

I am not sure if this approach will work, I mean if the caller-routine of the parent will proceed when the events of the child completed their job. Please leave a post if you give it a try ........
 
Upvote 0

Forum statistics

Threads
1,215,523
Messages
6,125,315
Members
449,218
Latest member
Excel Master

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