VBA macro works on one computer but when other use it, it attempts to save to the wrong save path and runtime errors

ZMathis

New Member
Joined
Dec 15, 2021
Messages
7
Office Version
  1. 2016
Platform
  1. Windows
Hello,

I have a Macro that un-shares the workbook then re-shares it after the macro has run. It works for me and when re-sharing it, it saves to the correct file path given in the vba. But when others in the office try it, it adds 7 or 8 random numbers at the end of the save address, then Runtime Error 1004s. I was thinking it might have something to do with the enabling content because someone suggested having them manually save after enabling content to unflag themselves as non-enabled in the system, but, while it did run the macro up to the last line (the re-sharing part) where it hadn't been doing before (before it would give the same error but all the macro accomplished before erroring out was un-sharing it), it still is giving that runtime error. When I hit the debug, it highlights the line below, with the correct save file path.

ActiveWorkbook.SaveAs "x:\example\filename.xlsm", , , , , , xlShared

But the Runtime Error 1004 is stating that the file path doesn't exist "x:\example\filename\0342242", the numbers are different every time.

Thank you in advance for any guidance.
 

Excel Facts

Will the fill handle fill 1, 2, 3?
Yes! Type 1 in a cell. Hold down Ctrl while you drag the fill handle.
Should probably provide more code so we can see what the code is doing before that line.
 
Upvote 0
It's not doing anything fancy it's just filling any formulas that got overwritten towards the end of the macro. The if just made sure certain criteria were met before running the macro. The 'Application.DisplayAlerts = False' happens right before the 'ActiveWorkbook.ExclusiveAccess'

End of macro.png
 
Upvote 0
This does not explain the random numbers on the end but if it is happening consistently for certain other users, it might be worth checking that their drive mapping for z: is identical to yours.
 
Upvote 0
I'm military we're all mapped to the same thing same way. I'll confirm though.
 
Upvote 0
I confirmed we're all mapped to the Z:\ . I know the lesser of all evils is to just make the user manually choose the save path every time, but, if I can "Army proof" it, I'd like to.
 
Upvote 0
I tried to record macro the save as to see how the computer would write the code and I added what it spat out in the code below, so I attempted to add the share argument onto the end of what it did, the next comma in the SaveAs path was the XLAccessMode argument but I'm just getting the compiled error when trying to run it, anyone have input on how to fix this error? If so maybe the save path would be more defined for the computer to understand better??

Comp Err.png
 
Upvote 0
Thanks that worked but, now it's back to square one where it works for me not others. Now I'm wondering if there's a function with the ActiveWorkbook.SaveAs to prompt the user to choose the save path, I've seen other threads about getting VBA to record what file path the user chooses but none of them use the SaveAs meaning it won't Share the Workbook.
 
Upvote 0

Forum statistics

Threads
1,214,518
Messages
6,119,985
Members
448,935
Latest member
ijat

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