Excel 2016: Custom Ribbon - Macros try to launch from the original workbook if you do a save as on the file

ajay_gajree

Well-known Member
Joined
Jul 16, 2011
Messages
518
An odd one

I have a file with several macros in it, when I used buttons on the worksheet an assign macros then when I save as the file(It is under development, so I regularly save new version with a new name) it works fine.

I have now removed the button on the worksheet and moved all the macros onto a custom ribbon.
When I now save as the file then when using any of the macros on the ribbon it opens the previous version of the file and uses the macros in that file!

Does anyone know what is going on and how this an be fixed?

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 workaround
-overwrite the original file every time you save the current file

Paste this code into the ThisWorkbook module of the latest file and amend path and file name to match what Excel is using via the ribbon
Code:
Private Sub Workbook_BeforeSave(ByVal SaveAsUI As Boolean, Cancel As Boolean)
    Const fPath = "[COLOR=#b22222]C:\folder\subfolder[/COLOR]"
    Const original = "[COLOR=#b22222]NameOfOriginalWorkbook.xlsm[/COLOR]"
    If ThisWorkbook.Name = original Then Exit Sub
    
    Application.DisplayAlerts = False
    ActiveWorkbook.SaveCopyAs fPath & "\"  & original
    Application.DisplayAlerts = True
End Sub
 
Last edited:
Upvote 0

Forum statistics

Threads
1,223,896
Messages
6,175,264
Members
452,627
Latest member
KitkatToby

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