Restricting VBA macros

  • Thread starter Thread starter halem2
  • Start date Start date
H

halem2

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
 
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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top