Why will it not save to where i need it

polska2180

Active Member
Joined
Oct 1, 2004
Messages
384
Office Version
  1. 365
Below is part of my script. My defult drive in excel is H:\ which is a network drive. My local drive is C:\ and that is where i'm trying to save this file C:\test\. Why is it not doing so and keeps saving to H:?

If there is nothing wrong let me know so that I can stop pulling out my hair and blame it on the PC, although I did try it on two different ones.

Code:
 Range("A65000").End(xlUp).Select
  
    Selection.Copy
    Worksheets("Variables").Visible = True
    Sheets("Variables").Select
    Range("A2").Select
    ActiveSheet.Paste
    Application.CutCopyMode = False
    Selection.TextToColumns Destination:=Range("A2"), DataType:=xlDelimited, _
        TextQualifier:=xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False, _
        Semicolon:=False, Comma:=False, Space:=False, Other:=True, OtherChar _
        :="/", FieldInfo:=Array(Array(1, 1), Array(2, 1), Array(3, 1)), _
        TrailingMinusNumbers:=True
        Range("E2").Select
    ActiveCell.FormulaR1C1 = "=RC[-4]&"".""&RC[-3]&"".""&RC[-2]"
    ChDir "C:\Test"
    ActiveWorkbook.SaveAs Filename:=Range("e2").Value & ".xls", FileFormat:=xlNormal, _
        Password:="", WriteResPassword:="", ReadOnlyRecommended:=False, _
        CreateBackup:=False
        'MsgBox ("You workbook was saved in the the following locatin " & "C:\Test" & "\" & Range("e2").Value & ".xls!")
        msg = msg & vbCrLf & "Your workbook was saved in the the following locatin " & "C:\Test" & "\" & Range("e2").Value & ".xls!"
                MsgBox msg, vbInformation, "VeoliaES - Important!!!!"
        
  
  Worksheets("working").Visible = False
  Worksheets("Variables").Visible = False
  

End Sub
 

Excel Facts

Ambidextrous Undo
Undo last command with Ctrl+Z or Alt+Backspace. If you use the Undo icon in the QAT, open the drop-down arrow to undo up to 100 steps.
Where are you specifying the path when saving?

If you don't specify the path then the file will probably be saved in the active directory.
 
Upvote 0
Yes I saw that eventually.

I suggest that rather than trying to use ChDir, incorporate C:\Test when you save.
Code:
ActiveWorkbook.SaveAs Filename:="C:\Test\" & Range("e2").Value & ".xls"
 
Upvote 0

Forum statistics

Threads
1,215,009
Messages
6,122,674
Members
449,091
Latest member
peppernaut

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