help! can't get the code to save in the workbook

whiteghost

Well-known Member
Joined
Nov 22, 2002
Messages
500
Hi,

PCC gave me the code for disabling the "saveas"

private sub Workbook_BeforeSave(ByVal SaveAsUl As Boolean, Cancel As Boolean)
cancel = SaveAsUl
end sub

This works fine until the file is saved and closed. On reopening the file, this code has not been saved.

what am I doing wrong?
 
Let me re-iterate the steps.

1. Insert breakpoint at Cancel = SaveAsUl.

2. Switch to Excel and hit Save.

3. This should take you back to the VBE. Switch back to Excel.

4. Goto File/Save As and save your workbook.

Let me know if this helps.
 
Upvote 0

Excel Facts

Do you hate GETPIVOTDATA?
Prevent GETPIVOTDATA. Select inside a PivotTable. In the Analyze tab of the ribbon, open the dropown next to Options and turn it off
ok. i followed the steps as you said. after saving in excel it did go back to the VBE screen and the line "cancel = SaveasUl" is yellow highlighted ( same as debug). Now, do I remove the breakpoint? and then save as?
 
Upvote 0
You don't need to touch anything in the VBE at this point. Just go back to Excel. Then File/Save As/Save.

Please post back.
 
Upvote 0
no joy. still did not save the code. Looks like i must have done something wrong. Trying again
 
Upvote 0
Keep trying because it worked for me. Tell you what, email me your workbook. Click on my profile to get my email address.
 
Upvote 0
finally got it to work. I have no clue about what i done differently, but it works.

thanks for all your patience and help
 
Upvote 0
it may still be en route... it was a large file and our mail server shunts large mail down the priorty list. Thanks once again
 
Upvote 0

Forum statistics

Threads
1,221,706
Messages
6,161,406
Members
451,702
Latest member
Kc3475

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