I want the file to open Read Only WITHOUT prompt

melodramatic

Board Regular
Joined
Apr 28, 2003
Messages
180
Office Version
  1. 365
Platform
  1. Windows
I have a macro that opens up a file of forms, makes customizations, and saves each worksheet in that file as it's own form in the new project. It works great (self pat on the back here), EXCEPT that I have users complain that they have to hit the Read-Only button. Obviously, having to wait the extra 10 seconds for the macro to pull the file up before hitting read only is 10 seconds totally wasted. They NEED to hit the macro button then wander off to the coffee room.

Cough cough ... now that I'm past the grrr point...

The "Forms for Macro" file has been saved with a password to modify. I don't need any users going in an messing with the coding in that file. How do I set the Workbooks.Open so that it doesn't prompt them for the password, but instead just opens the file read only?

Thanks so much for helping!

Code:
Sub CompleteForms()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

    
    Workbooks.Open Filename:= "P:\LAB\TESTING PROJECTS\MACRO\Forms for Macro.xlsx"
    Sheets("List").Select
 

Excel Facts

Why are there 1,048,576 rows in Excel?
The Excel team increased the size of the grid in 2007. There are 2^20 rows and 2^14 columns for a total of 17 billion cells.
One small thing I just thought of - I don't mind using my password in the macro, if it can be used to bypass the prompt, and as long as I can have it open in the suggested read-only, as well.

So, that would change my coding (thus far), to:

Code:
Sub CompleteForms()

Application.ScreenUpdating = False
Application.DisplayAlerts = False

    
    Workbooks.Open Filename:= "P:\LAB\TESTING PROJECTS\MACRO\Forms for Macro.xlsx", Password:=PWord
    Sheets("List").Select

So, what do I do after that to have it accept the read only suggestion?
 
Upvote 0
Bump? Please, I know this has to be easy for someone not as newbie to VBA as I am.
 
Upvote 0
Have you looked in Help at the arguments for Workbooks.Open?
 
Upvote 0
I've tried, and all I get is errors.

MSDN shows the following: expression .Open(FileName, UpdateLinks, ReadOnly, Format, Password, WriteResPassword, IgnoreReadOnlyRecommended, Origin, Delimiter, Editable, Notify, Converter, AddToMru, Local, CorruptLoad)

So, what I've tried is this:
Code:
    Workbooks.Open (Filename:= "P:\LAB\TESTING PROJECTS\MACRO\Forms for Macro.xlsx", ReadOnly:-True)
I get a Compile error: Expected: named parameter

I know it's something simple that I'm doing wrong - but what???
 
Upvote 0
I do not have any file to try but maybe something like

Application.ActiveProtectedViewWindow.Edit
 
Upvote 0
No parens, and the hyphen should be an equals sign:
Code:
  Workbooks.Open Filename:="P:\LAB\TESTING PROJECTS\MACRO\Forms for Macro.xlsx", _
                 ReadOnly:[B][COLOR="#FF0000"][SIZE=3]=[/SIZE][/COLOR][/B]True
 
Upvote 0
An oops on me typing it in - I did have the "=" rather than "-" - but, meanwhile

THANK YOU! Removing the parenthesis took care of the problem. :)
 
Upvote 0

Forum statistics

Threads
1,214,923
Messages
6,122,283
Members
449,075
Latest member
staticfluids

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