View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Tom Ogilvy Tom Ogilvy is offline
external usenet poster
 
Posts: 27,285
Default 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:(


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