PDA

View Full Version : Solved: Small Modification VBA code help needed!!



megha
01-19-2012, 08:23 AM
The following code worked fine for me. It create folder automatically by month and year and SaveAs word 2003 files with current date, time and Shift as a file name. I would like to add Team as the file name to my current macro script. Can someone please help me? I would really really appriciate. Thank you so much.


Sub Document_Open()
Me.Shift.List = Split("Day Night")
Me.Team.List = Split("A B C D")
End Sub
Private Sub CommandButton1_Click()
Dim sFileName As String
Dim sPath As String
CommandButton1.Enabled = False
sFileName = Format(DateValue(Now()), "mmm_dd_yyyy") & "_" & Shift.Value & _
Format(TimeSerial(Hour(Now()), Minute(Now()), Second(Now())), "hh_mm_ss_AM/PM")
If Len(Dir("\\C:\Common\ (file://\\C:\Common\)" & Format(DateValue(Now()), "mmm_yyyy"), vbDirectory)) = 0 Then
MkDir "\\C:\Common\ (file://\\C:\Common\)" & Format(DateValue(Now()), "mmm_yyyy")
End If
sPath = "\\C:\Common\ (file://\\C:\Common\)" & Format(DateValue(Now()), "mmm_yyyy")
sFileName = sFileName & ".doc"
ActiveDocument.SaveAs FileName:=sPath & "\" & sFileName, FileFormat:=xlNormal, ReadOnlyRecommended:=False
MsgBox "Checklist has been saved"
ThisDocument.Close SaveChanges:=False
End Sub

mikerickson
01-21-2012, 12:09 AM
megha,

Is this thread solved? or did you mark it by mistake?

Since this is in the Mac forum, I'm guessing that you want to convert that code to run on a Mac?

I find it easiest to work with folders in AppleScript via the MacScript command.