ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Restricting VBA macros (https://www.excelbanter.com/excel-programming/310210-restricting-vba-macros.html)

halem2[_25_]

Restricting VBA macros
 
How can I force a workbook to always use the macros stored in tha
workbook even if I do a file save as? The macros in the original file
after I do a save as, point to the newly saved as file, so when I ope
the original one, all the macros faile 'cause they are pointing to th
saved as file.

HELP!!!!! thanks:( :confused

--
Message posted from http://www.ExcelForum.com


Tom Ogilvy

Restricting VBA macros
 
Write code to go through and change them back. (I assume you are talking
about toolbar onaction macros).

Here is some code posted recently by Bernie Deitrick:

Sub RepairUserDefinedButtons3()
Dim CmdBar As CommandBar
Dim i As Integer
On Error GoTo ErrorReading:

For Each CmdBar In CommandBars
For i = 1 To CmdBar.Controls.Count
If CmdBar.Controls(i).BuiltIn = False Then
If InStr(1, CmdBar.Controls(i).OnAction, _
"my-macros.xls") Then
CmdBar.Controls(i).OnAction = _
Replace(CmdBar.Controls(i).OnAction, _
"my-macros.xls", "my-macros.xla")
End If
End If
ErrorReading:
Next i
Next CmdBar
End Sub


Change my-macros.xls to the saved as workbook name and my-macros.xls to the
original workbook name.

--
Regards,
Tom Ogilvy

"halem2 " wrote in message
...
How can I force a workbook to always use the macros stored in that
workbook even if I do a file save as? The macros in the original file,
after I do a save as, point to the newly saved as file, so when I open
the original one, all the macros faile 'cause they are pointing to the
saved as file.

HELP!!!!! thanks:( :confused:


---
Message posted from http://www.ExcelForum.com/





All times are GMT +1. The time now is 09:17 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com