Results 1 to 9 of 9
  1. #1
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Date Stamp Word Documents (XP)

    Found this code somewhere and would like to know what modifications would have to be made in order for it to ask for the name by which you want to save the document. Presently it saves it with today's date and Blah, Blah.

    Sub DatestampFile()
    Dim strDate As String
    strDate = Format(Date, "dd.mm.yyyy")
    If Documents.Count > 0 Then
    Set dlgProp = Dialogs(wdDialogFileSummaryInfo)
    dlgProp.Title = strDate & " Blah, Blah "
    dlgProp.Execute
    ActiveDocument.SaveAs (strDate & " Blah, Blah")
    End If
    End Sub

    Thanks

    Again, I apologize for posting this in Visio by mistake.

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date Stamp Word Documents (XP)

    Change

    ActiveDocument.SaveAs (strDate & " Blah, Blah")

    to

    Application.Dialogs(wdDialogFileSaveAs).Show

  3. #3
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Stamp Word Documents (XP)

    Thanks Hans. However, but by making the change the date stamp does not show up.

  4. #4
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date Stamp Word Documents (XP)

    With Application.Dialogs(wdDialogFileSaveAs)
    .Name = strDate & " Blah, Blah "
    .Show
    End With

  5. #5
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Stamp Word Documents (XP)

    Sorry for the delay in responding. I have tried this line of code as suggested. However when I run the code I get "Compile Error: Invalid use of Property".

    Here is the code as it presently written.

    Sub DatestampFile()
    Dim strDate As String
    strDate = Format(Date, "dd.mm.yyyy")
    If Documents.Count > 0 Then
    Set dlgProp = Dialogs(wdDialogFileSummaryInfo)
    dlgProp.Title = strDate & " Blah, Blah "
    dlgProp.Execute
    Application.Dialogs (wdDialogFileSaveAs)
    .Name = strDate & " Blah, Blah"
    .Show
    End With
    End Sub

  6. #6
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Date Stamp Word Documents (XP)

    Assuming you get the dialog with the Debug button, click Debug and let us know what line is highlighted as having the problem. If the code is in a form, this usually doesn't work, but if it is in a regular module, it should help determine which property has a problem.

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Date Stamp Word Documents (XP)

    On second glance, I think you forgot the With in the line above .Name -- without which the leading dot on .Name has no meaning.

  8. #8
    3 Star Lounger
    Join Date
    Aug 2004
    Posts
    361
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Date Stamp Word Documents (XP)

    Added your With and and End if later in routine.

    Here is the routine with your With added.

    Sub DatestampFile()
    Dim strDate As String
    strDate = Format(Date, "dd.mm.yyyy")
    If Documents.Count > 0 Then
    Set dlgProp = Dialogs(wdDialogFileSummaryInfo)
    dlgProp.Title = strDate & " Blah, Blah "
    dlgProp.Execute
    With Application.Dialogs (wdDialogFileSaveAs)
    .Name = strDate & " Blah, Blah"
    .Show
    End With
    End If (Also required an End If statement)
    End Sub

  9. #9
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Date Stamp Word Documents (XP)

    I had to declare dlgProp because I have set the Visual Basic Editor to require explicit declaration of all variables:

    Dim dlgProp As Dialog

    but then, the code ran without problems in Word 2002 SP-3.

Posting Permissions

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