PDA

View Full Version : Excel adds wrong pathname to macro name



Salsasteve
06-28-2009, 01:42 AM
When I save my project to a memory stick, excel changes the macros assigned to my toolbar buttons by adding the pathname of the memory stick.

Running the file from the memory stick is okay, but from the C drive, the macros retain the association with the memory stick, even if I do a "save as" to the C drive.

I have to go to Tools/customize and reset all the assignments manually to put it right. Similarly, when I transfer the file to the desktop at work, I have to manually re-assign the macros.

However, if I delete the file on C, open it from the memory stick and then save it to C, the buttons work okay, but the filename (without the path) has been added to the macro names!

How can I get excel to use the macros in the currently open workbook, so that the pathname is irrelevant?

Any help would be appreciated!

Steve

GTO
06-28-2009, 03:48 AM
Hi Steve,

Not sure what's happening, but:
ThisWorkbook.Path
...may resolve issues.

If not, I would suspect we'd need to see the code and some specifics, such as whether you are plunking th path and/or fullname in a cell somewhere, or, an example workbook.

Hope this helps,

Mark

Salsasteve
06-28-2009, 06:25 AM
Hi Mark,

I don't have any file operations in my spreadsheet code, so don't think it can be anything to do with pathnames, as I haven't used any! Unless you had a specific method in mind?

Steve

mikerickson
06-28-2009, 07:21 AM
You could write an Open event that redirects the toolbar controls' to ThisWorkbook.

Just to be safe, it could also test for the existence of the custom controls and create them if they didn't exist in the current environment.

Salsasteve
06-28-2009, 10:40 AM
Hi Mike,

I would appreciate some advice about how to code that in a workbook open event.

Thanks,

Steve