How to lock the path to a macro

  • Thread starter Thread starter JVS
  • Start date Start date
J

JVS

Can someone tell me how I can lock the path to a macro that I assigned to a
command button?

Every time I copy the spread sheet from the server to my hard drive the path
to the macro is changed

to match the location of the work book.

Using Excel 2000.



Thanks!
Johnny
 
No. "It is a feature, not a bug." <<grin>>

Regards
BrianB
==============================================
 
Is there a work around or an alternate solution?
I have a time sheet workbook that I am about to issue to approx 200
associates.
I'd like to issue it with no macro's, but was hoping to use a command button
to link to a second "master book" that would contain the macros required to
fix what the users mess up.

Any help would be greatly appreciated!
Thanks!
Johnny
 
Hi Johnny,

Have you considered opening a ReadOnly copy of the Master
Book and shifting it behind the Slave Book? If it's
open, your button clicks won't need a path (See below).
The following may give you some ideas:

'SlaveBook.xls
'IN A SHEET OBJECT
Private Sub CommandButton1_Click()
Call OpenMaster
End Sub

Private Sub CommandButton2_Click()
'USE SOME VALID MasterBook.xls PROCEDURE HERE
Application.Run "MasterBook.xls!TstMasterSub"
'NO PATH REQUIRED HERE
End Sub


'SlaveBook.xls
'IN A MODULE
'CALL FROM A BUTTON CLICK, AUTO_OPEN, OR??
Sub OpenMaster()
Application.ScreenUpdating = False
Workbooks.Open _
Filename:="\\your\fixed\path\to\MasterBook.xls", _
ReadOnly:=True
ThisWorkbook.Activate
End Sub


'SlaveBook.xls
'IN THE WORKBOOK OBJECT
'DON'T LEAVE THE MASTERBOOK.XLS FILE OPEN ALONE
Private Sub Workbook_BeforeClose(Cancel As Boolean)
For Each wb In Workbooks
If wb.Name = "MasterBook.xls" Then _
wb.Close savechanges:=False
Next
End Sub


'MasterBook.xls
'IN THE WORKBOOK OBJECT
Private Sub Workbook_Open()
If Workbooks.Count = 1 Then
ThisWorkbook.Close savechanges:=False
Else
'TRIGGER ANY VALID AUTO_OPENS HERE
MsgBox "Master Book Opened"
End If
End Sub

Best Regards,
Walt Weber
 
Back
Top