find the files loction and then saving a copy next to it

Grizlore

Active Member
Joined
Aug 22, 2006
Messages
259
Hi,
I have a spreadsheet, which will be saved somewhere on our company's external drive on another site. I do not know where this will be and this could change.
This spreadsheet was planned to be copied automatically into one of my drives and then imported into another spreadsheet. However as this files has all kinds of Macros, I think it would be easier to, at the time of savng, have the initial master spreadsheet save a text file version of the required data next to it in the same folder.

So my question to you guys.....

How do i find where a file is saved (eg \\server1\public\Department\Its_here\) as i would need that to enable this text file to be saved in the same folder, wherever this file goes.

Any help would be appreciated
 
No, no errors.... BUT.... I have fixed it, I think

Code:
   CurrentLoc = ThisWorkbook.Path
    
    Sheets("Data").Select
    Sheets("Data").Copy
    
    'ChDir CurrentLoc
      
    ActiveWorkbook.SaveAs Filename:= _
        CurrentLoc + "\" + "TareWeightText.txt", FileFormat:= _
        xlText, CreateBackup:=False
    Windows("TareWeightText.txt").Activate
    ActiveWorkbook.Close Savechanges:=False
     
    Windows("Tare Weight Records.xls").Activate
    Range("A2").Select

So this concatenation seems to have fixed it.... ActiveWorkbook.SaveAs Filename:= _ CurrentLoc + "\" + "TareWeightText.txt

Thanks for ALL you help Andrew!
 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.

Forum statistics

Threads
1,215,734
Messages
6,126,545
Members
449,316
Latest member
sravya

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