Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Suffolk, England
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatic footers (97)

    I have got an AutoNew macro that prompts the user to save the document, and then creates a footer with the filename + path in it. This works, except for when Word is first opened. Creating an Autoexec macor won't work as the macor runs before the new document is created. Has anyone any ideas?
    Thanks

  2. #2
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Automatic footers (97)

    How about putting the code in an AutoSave macro, with an extra check to see if the footer has already been created.

    StuartR

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,927
    Thanks
    4
    Thanked 295 Times in 267 Posts

    Re: Automatic footers (97)

    Is there a reason you are not using the Filename field with the p switch to get the path? This could be in the template to start with and you wouldn't need the autonew macro unless you wanted to update the field to keep it fresh.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Suffolk, England
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatic footers (97)

    Thanks for your reply.
    I was using an AutoNew macro as I want the filename to appear in the footer both when the document is opened again and when it's printed, so having document1 in the footer is not what I want. Ideally I could do with a macro that prompts for a filename before printing. The AutoNew macro does the job except for when Word first opens.

  5. #5
    Plutonium Lounger
    Join Date
    Nov 2001
    Posts
    10,550
    Thanks
    0
    Thanked 7 Times in 7 Posts

    Re: Automatic footers (97)

    To get the document name updated when you print you could use a Field with the document name in the footer and set your print options to update fields (Tools => Options => Print => Update Fields)

    StuartR

  6. #6
    2 Star Lounger
    Join Date
    Oct 2001
    Location
    Suffolk, England
    Posts
    134
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatic footers (97)

    Thanks - but---
    That won't solve the problem of document1 not being saved before it is printed.

  7. #7
    Uranium Lounger
    Join Date
    Dec 2000
    Location
    Los Angeles Area, California, USA
    Posts
    7,453
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatic footers (97)

    Hi Allison:
    For the particular template in question, you could have a macro that puts a FileSave command in a Print macro (I can't tell you how because I'm not a VBA expert). Then when you tried to print an unsaved document, it would prompt for a filename & then save.

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

    Re: Automatic footers (97)

    You could do something like this:

    <pre>Sub FilePrint()
    'Require document to be saved prior to printing
    If ActiveDocument.Saved = False Then
    On Error Resume Next
    ActiveDocument.Save
    If Err.Number = 4198 Then
    MsgBox "You must save before printing!"
    Exit Sub
    End If
    On Error GoTo 0
    End If
    'Display print dialog
    Dialogs(wdDialogFilePrint).Show
    End Sub

    Sub FilePrintDefault()
    FilePrint
    End Sub</pre>

    If you don't want to force a save to an already saved document that has additional changes, you could do this instead:
    <pre>Sub FilePrint()
    'Test for ever having been saved
    On Error Resume Next
    Dim varTime As Variant
    'The next line will generate an error if the value is missing
    varTime = ActiveDocument.BuiltInDocumentProperties(wdPropert yTimeLastSaved)
    If Err.Number <> 0 Then
    Err.Clear
    ActiveDocument.Save
    If Err.Number = 4198 Then
    MsgBox "You must save before printing!"
    Exit Sub
    End If
    End If
    On Error GoTo 0
    'Display print dialog
    Dialogs(wdDialogFilePrint).Show
    End Sub

    Sub FilePrintDefault()
    FilePrint
    End Sub
    </pre>

    Hope this helps. (Note: only tested in Word 2000.)

Posting Permissions

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