Button OnAction Macro Assignment "drive" letter getting reassigned

lukez

Board Regular
Joined
Nov 6, 2014
Messages
56
Hello,

I can't find any topics on this issue.
I create a button using vba and assign a macro using onaction.
Code:
.OnAction = "'c:\data\macro.xla'!copy"
The macro continues and saves the file to c:\data\temp\

Everything works fine with the button at this point. I can also saveas to a different drive (shared drive for example) z:\
The button still works in the new location.

Now, if I drag and drop (copy/paste) the file from c:\data\temp into z:\data\temp the button stops working. It says z:\data\macro.xla'!copy does not exist.
Any insights as to how I can hard code the drive letter into the button so that I can freely move the files around and not have to saveas in order to move it?

Thanks!
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
Posting full button code incase that's more helpful:

Code:
    ActiveSheet.Buttons.Add(10, 30, 72, 25).Select
    With Selection
        .OnAction = "'c:\data\downloads\macro.xla'!copy"
        .Caption = "Copy?"
        .Font.Name = "Arial"
        .Font.FontStyle = "Bold"
        .Font.Size = 8
    End With
 
Last edited:
Upvote 0
Update:
I have narrowed down the issue to relocating the file to a sharepoint library. It works if I move it between drives but errors out when I put it on sharepoint. Error says "We can't connect to 'https//sharepoint.com/data/downloads/macro.xla'!copy"' Please make sure you're using the correct web address
 
Last edited:
Upvote 0

Forum statistics

Threads
1,224,820
Messages
6,181,157
Members
453,021
Latest member
Justyna P

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top