SaveASUI doesn't work as it's being called by another macro

gooniegirl180

Board Regular
Joined
Aug 13, 2003
Messages
152
Hi all,

I have a file that my users are not permitted to save, but I want my staff to be able to modify and save. I have an old macro from mikerikson which works if my team or I wants to save this master file and enters the appropriate password, thus:

Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If Not (SaveAsUI) Then
SavePassword = (Application.InputBox("Enter Password to Save This Masterfile", Type:=2) <> "Barrie")
End If
End Sub

However, the file also has another macro which saves the file as another name, which doesn't require a password - but when that one is run, it calls this one and asks for the password because, I'm guessing, there is no Save-As User Interface.

What code do I have to put into the SAVE AS macro to pass a password to the Workbook_BeforeSave routine, and how do I modify that one to prevent the InputBox popping up?

BTW, regardless of whether I press CANCEL or type in the password, when the Workbook_BeforeSave messagebox pops up, it goes back to the calling macro and does the SAVEAS anyway. Which is OK, but will confuse the heck out of my users....


Thanks,
Gooniegirl180, stuck in a loop
 

Excel Facts

Square and cube roots
The =SQRT(25) is a square root. For a cube root, use =125^(1/3). For a fourth root, use =625^(1/4).
In the other macro put
Code:
Application.EnableEvents =False
just before the SaveAs line & then put
Code:
Application.EnableEvents =True
straight after that line.
 
Upvote 0
You're welcome & thanks for the feedback
 
Upvote 0

Forum statistics

Threads
1,224,818
Messages
6,181,151
Members
453,021
Latest member
Justyna P

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