Macro Not working when I share with other co-workers

RMONTE

New Member
Joined
May 23, 2018
Messages
1
I have a simple macro that saves a sheet in the workbook as a PDF. It works perfectly on my computer but when I share with co-workers it doesn't work. It appears as though the ChDir is pointing to a path specific to my computer. Is there a way for that to be dynamic to the computer it's running on.
Here's that portion of the code:

ChDir "C:\Users\RMONT\Desktop"
 

Excel Facts

How to create a cell-sized chart?
Tiny charts, called Sparklines, were added to Excel 2010. Look for Sparklines on the Insert tab.
Maybe try this:

Code:
ChDir "C:\Users\" & Environ("UserName") & "\Desktop"

not sure, but it's worth a try...
 
Upvote 0
Another option
Code:
ChDir Environ("userprofile") & "\Desktop"
 
Upvote 0
UserProfile is a new one on me...good call. :)

I guess I should spend 10 seconds on google and find a list of all the environ arguments lol.
 
Upvote 0

Forum statistics

Threads
1,224,813
Messages
6,181,106
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