I have an Excel XP file that has some macros stored in a module. These
macros are used in a custom toolbar. I didn't want the end users to
be able to see the macros when they choose Tools, Macro, Macros, so I
used Option Private Module in the VBA module. I also set a password
on the VBA project, so it's not viewable either.
When I go into the customize area for the toolbars and I look at the
macro's that are assigned to a particular menu item, it displays
'filename.xls'!mnuMacro which works great. The problem is that after I
move the Excel file, then the reference to the macro's includes the
path of the original file ie. 'c:\my document\..filename.xls!mnuMacro
I need to be able to put this on other users computers, so it needs to
always refer to the current file.
Any ideas, or workarounds.
Thanks |
Request for Question Clarification by
answerguru-ga
on
04 Nov 2003 09:29 PST
Hi there,
Have you tried storing the macro in ThisWorkbook? If your users are
always going to be working within a specific file to invoke the macro
there is really no need to place your code in a seperate module. Plus,
you change the scope of the macro by putting it in this area so it
wouldn't contain and directory information.
I've posted this (informally) as a clarification as I'm not sure if it
would work in your case. Please do let me know if it does the trick
and I will post this as an official answer :)
Thanks,
answerguru-ga
|
Clarification of Question by
softcom-ga
on
04 Nov 2003 10:07 PST
Hi
Actually, there is a second Excel file involved. The first file, has
the toolbar, so I think it needs to be in a module. The second file
has access to the first files toolbar, along with all the functions
that it provides. I'll try it in the workbook, just to be sure.
|
Clarification of Question by
softcom-ga
on
04 Nov 2003 14:46 PST
I tried moving it into the workbook, but that just caused a host of other problems.
Any other ideas?
|
Request for Question Clarification by
answerguru-ga
on
04 Nov 2003 15:51 PST
Unfortunately not...perhaps another researcher will be able to assist you.
answerguru-ga
|
Clarification of Question by
softcom-ga
on
04 Nov 2003 16:12 PST
I've been able to narrow down the problem further. Try the following:
- Start a new workbook.
- Record a macro in the workbook.
- Create a button on the toolbar and assign the macro to the button
- save the file
- close excel and then copy the file to a new location on your hard
drive
- open the copy and try the button
The reference for the button gets changed to the original location of
the file, so that when you click on it, excel tries to open the
original file, but can't because the files have the same name. If you
go and modify the path for the button - removing the path portion,
then it works fine.
|