PDA

View Full Version : Solved: Saving files



Scooter172
02-15-2011, 09:08 PM
I use the following code to auto save a new document to a given folder. This works fine in that it names the file, but the "path" assigned and the result of the location are differant. Once I open the new document it saves to "H:\LRT\RCCDailyOpsLogs" and not the specidied path of "H:\LRT\RCCDailyOpsLogs\CallOffs" I have this code in several other docs and it works fine for those named paths.

Private Sub Document_New()
Dim MyPath As String

MyPath = "H:\LRT\RCCDailyOpsLogs\CallOffs"
ActiveDocument.SaveAs FileName:=MyPath & "Daily Absenteeism Report" & _
Format(Date, "mm_dd_yyyy ddd") & ".docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub

Tinbendr
02-16-2011, 06:10 AM
It's missing the trailing slash. (Either at the end of the path string or at the beginning of the filename.)

MyPath = "H:\LRT\RCCDailyOpsLogs\CallOffs\"


David

Scooter172
02-16-2011, 08:53 AM
thanks

Scooter172
02-16-2011, 05:11 PM
How then in the format line would I add the time to the already working Date?

Tinbendr
02-16-2011, 08:18 PM
Private Sub Document_New()
Dim MyPath As String

MyPath = "H:\LRT\RCCDailyOpsLogs\CallOffs\"
ActiveDocument.SaveAs FileName:=MyPath & "Daily Absenteeism Report" & _
Format(Date, "mm_dd_yyyy ddd") & Format(Time, "_hh:mm") & ".docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub

Scooter172
02-16-2011, 09:05 PM
I tried but code broke due to the : in time format. this is what I used to resolve.

[VBA] Private Sub Document_New()
Dim MyPath As String

MyPath = "H:\LRT\RCCDailyOpsLogs\CallOffs\"
ActiveDocument.SaveAs FileName:=MyPath & "Daily Absenteeism Report" & _
Format(Date, " mm_dd_yyyy ddd ") & Format(Time, " _hh_mm ") & ".docx", _
FileFormat:=wdFormatXMLDocument, LockComments:=False, Password:="", _
AddToRecentFiles:=True, WritePassword:="", ReadOnlyRecommended:=False, _
EmbedTrueTypeFonts:=False, SaveNativePictureFormat:=False, SaveFormsData _
:=False, SaveAsAOCELetter:=False
End Sub
/VBA]

Scooter172
02-16-2011, 09:07 PM
For what ever reason I entered code using tool but it does not appear here correctly.

Tinbendr
02-16-2011, 09:14 PM
I tried but code broke due to the : in time format.Akk! :doh:

Glad you got it sorted.

David

Tinbendr
02-16-2011, 09:16 PM
For what ever reason I entered code using tool but it does not appear here correctly.Missing the left bracket in the closing tag. "["/VBA]

Scooter172
02-16-2011, 11:07 PM
How do I mark something solved

Tinbendr
02-17-2011, 05:37 AM
How do I mark something solved
At the top of this message under Thread Tools.

Scooter172
02-18-2011, 07:58 PM
At the top of this message under Thread Tools.
When I click on it it sends me to the bottom of the page with no option to show closed.