I want to enable the Save and saveas option only for the file name "Rhel.xlsx" and want it to disabled for every other file name but its not working

siddo

Board Regular
Joined
May 26, 2020
Messages
106
Office Version
  1. 365
  2. 2019
Platform
  1. Windows
VBA Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
If sfilename ="Rhel.xlsx" Then
Cancel = False
Else
Cancel = True
MsgBox "Contact Author"
End If
End Sub
 

Excel Facts

What does custom number format of ;;; mean?
Three semi-colons will hide the value in the cell. Although most people use white font instead.
You will need to put the code in the Rhel workbook & save it as an xlsm file.
 
Upvote 0
You will need to put the code in the Rhel workbook & save it as an xlsm file.
Yes, have saved this code in Thisworkbook section with the file name Rhel.xlsm so basically I want to disable save and saveas for Rhel.xlsm but not for Rhel.xlsx though its not working
 
Upvote 0
The code will only work on the workbook it's in, so it will not affect the Rhel.xlsx workbook.
 
Upvote 0
Yes, have saved this code in Thisworkbook section with the file name Rhel.xlsm so basically I want to disable save and saveas for Rhel.xlsm but not for Rhel.xlsx though its not working
I have created a macro file to which if certain outputs are feed in Rhel.xlsm file it computes and generate other file named Rhel.xlsx
 
Upvote 0
The code will only work on the workbook it's in, so it will not affect the Rhel.xlsx workbook.
I have created a macro file to which if certain outputs are feed in Rhel.xlsm file it computes and generate other file named Rhel.xlsx
 
Upvote 0
Sorry but I don't understand what you are saying.
 
Upvote 0
Sorry but I don't understand what you are saying.
I have created a macro file for my organisation in which if you put certain database outputs it computes the whole thing and returns the result in Rhel.xlsx so all I want to do is I dont want a user to save My macro workbook I just want them to give the permission to save Rhel.xlsx file. I hope you understand.. Thanks for the help anyways.
 
Upvote 0
How are you creating the Rhel.xlsx file?
 
Upvote 0

Forum statistics

Threads
1,214,975
Messages
6,122,538
Members
449,088
Latest member
RandomExceller01

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