Thread: [Solved] saveAs ChDir _
View Single Post
 
Old 11-03-2011, 05:22 AM
tinfanide tinfanide is offline Windows 7 64bit Office 2010 32bit
Expert
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default saveAs ChDir _

Code:
Sub saveFile()

Dim newFile As String, fName As String
fName = "test"
newFile = fName & " " & Format$(Date, "yyyy-mm-dd")
ChDir _
"C:\Users\Tin\Desktop\"
ActiveWorkbook.SaveAs Filename:=newFile


End Sub
But if I don't use ChDir _
It is fine.
If I use ChDir _
even the location path is correct
the file will be saved in my Document Folder
Why?

Code:
Sub saveFile()

Dim newFile As String, fName As String
fName = "test"
newFile = fName & " " & Format$(Date, "yyyy-mm-dd")

ActiveWorkbook.SaveAs "C:\Users\Tin\Desktop\" & newFile

End Sub
Reply With Quote