Consulting

Results 1 to 2 of 2

Thread: Solved: Small Modification VBA code help needed!!

  1. #1
    VBAX Regular
    Joined
    Oct 2009
    Posts
    69
    Location

    Solved: Small Modification VBA code help needed!!

    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.

    [VBA]
    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\" & Format(DateValue(Now()), "mmm_yyyy"), vbDirectory)) = 0 Then
    MkDir "\\C:\Common\" & Format(DateValue(Now()), "mmm_yyyy")
    End If
    sPath = "\\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
    [/VBA]

  2. #2
    Mac Moderator VBAX Guru mikerickson's Avatar
    Joined
    May 2007
    Location
    Davis CA
    Posts
    2,778
    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.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •