Use current file path to indetify folder location

daren.beaney

New Member
Joined
Jun 14, 2011
Messages
16
Hi, I have this code that works fine for majority however the way people access the folder from different offices is causing an issue. Basically if I use the direct path as shown in the code, it doesn't work, so I wondered if there is a way for the code to identify current path and then place the backup copy of the file into the Archive folder, which is a folder in the current file location.

Hope that makes sense.

Here's my current code:
Code:
ThisWorkbook.SaveCopyAs "F:\Adfact\Adelphi Modernisation\Business Change & Comms\01 Stakeholders\Archive\" _
& Replace(ThisWorkbook.Name, ".xlsm", " (" & Environ("USERNAME") & Format(Now, "dd-mm-yy hhmm") & ").xlsm")

Thanks in advance.
 

Excel Facts

Bring active cell back into view
Start at A1 and select to A9999 while writing a formula, you can't see A1 anymore. Press Ctrl+Backspace to bring active cell into view.
Perhaps :-
Code:
wbPath = ThisWorkbook.Path
ThisWorkbook.SaveCopyAs wbPath & "\Archive\" _
& Replace(ThisWorkbook.Name, ".xlsm", " (" & Environ("USERNAME") & Format(Now, "dd-mm-yy hhmm") & ").xlsm")

NB I have changed the reference from ActiveWorkbook to ThisWorkbook for continuity.

hth
 
Upvote 0
Perhaps :-
Code:
wbPath = ThisWorkbook.Path
ThisWorkbook.SaveCopyAs wbPath & "\Archive\" _
& Replace(ThisWorkbook.Name, ".xlsm", " (" & Environ("USERNAME") & Format(Now, "dd-mm-yy hhmm") & ").xlsm")

NB I have changed the reference from ActiveWorkbook to ThisWorkbook for continuity.

hth

Thanks Mike that worked a treat!
 
Upvote 0

Forum statistics

Threads
1,215,753
Messages
6,126,678
Members
449,327
Latest member
John4520

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