Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-03-2011, 05:22 AM
tinfanide tinfanide is offline saveAs ChDir _ Windows 7 64bit saveAs ChDir _ Office 2010 32bit
Expert
saveAs ChDir _
 
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
  #2  
Old 11-04-2011, 03:57 AM
macropod's Avatar
macropod macropod is offline saveAs ChDir _ Windows 7 64bit saveAs ChDir _ Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi tinfanide,

Try:
Code:
Sub saveFile()
Dim Strfold As String, StrNewFile As String, StrfName As String
StrfName = "test"
Strfold = "C:\Users\Tin\Desktop\"
StrNewFile = Strfold & fName & " " & Format$(Date, "yyyy-mm-dd")
ActiveWorkbook.SaveAs FileName:=StrNewFile
End Sub
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 11-04-2011, 07:39 PM
tinfanide tinfanide is offline saveAs ChDir _ Windows 7 64bit saveAs ChDir _ Office 2010 32bit
Expert
saveAs ChDir _
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

Oh... does that mean ChDir is not for locating directories?
Reply With Quote
  #4  
Old 11-05-2011, 01:18 AM
macropod's Avatar
macropod macropod is offline saveAs ChDir _ Windows 7 64bit saveAs ChDir _ Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Hi tinfanide,

ChDir is for changing directories, not for finding them.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 11-05-2011, 01:40 AM
tinfanide tinfanide is offline saveAs ChDir _ Windows 7 64bit saveAs ChDir _ Office 2010 32bit
Expert
saveAs ChDir _
 
Join Date: Aug 2011
Posts: 312
tinfanide is on a distinguished road
Default

I see. Thanks.
Reply With Quote
Reply

Thread Tools
Display Modes


Other Forums: Access Forums

All times are GMT -7. The time now is 08:27 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft