Page 1 of 2 12 LastLast
Results 1 to 15 of 23
  1. #1
    Bronze Lounger
    Join Date
    Jan 2001
    Posts
    1,418
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Automatically include file-path in header/footer

    Anyone know of a way to automatically include a Word document's filepath in a header/footer, along with the page number of the document?

  2. #2
    Gold Lounger
    Join Date
    Dec 2000
    Location
    New Hampshire, USA
    Posts
    3,386
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Automatically include file-path in header/footer

    Insert the FILENAME field, using the /p option, and also the PAGE field.

  3. #3
    Bronze Lounger
    Join Date
    Jan 2001
    Posts
    1,418
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Automatically include file-path in header/footer

    Thanks, Howard.

  4. #4
    ConradE
    Guest

    Re: Automatically include file-path in header/footer

    So is there a way to insert it in the footer on the *last* page of a letter? I've been using the approach described above, but it appears on the first page. Using a "new footer" approach is fine if you consistently have two-page letters, but this is not useful in a letter template.

  5. #5
    susabelle
    Guest

    Re: Automatically include file-path in header/footer

    You have to create a section break, not a regular page break, in order to use different footers on different pages. Instead of a page break, to go insert|break and choose next page. Then you can create a different footer on the second page, and leave the first page with no footer.

    -Susabelle

  6. #6
    Super Moderator
    Join Date
    Dec 2000
    Location
    New York, NY
    Posts
    2,970
    Thanks
    3
    Thanked 29 Times in 27 Posts

    Re: Automatically include file-path in header/footer

    If you're creating a multipage letter, and the special footer must only be on the last page, then using a section break is the only way to do this.

    However, if the letter is only going to be two pages, or if it's OK to have the different footer on all continuation pages (just not appear on the first page), then there's a better way than using a section break:

    Create your letter template initially as a one-page document. In Page Setup>Layout tab, under Headers and Footers put a checkmark next to "Different first page".

    Now back in your template, temporarily add enough text to go to a second page. Navigate to the footer for the second page footer. Place your continuation footer content in this footer. (Note that this footer will say simply "Footer" - if you navigate back to the first page footer, it will say "First Page Footer".

    Now back in the body of the document, delete the extra text, so that the letter is only one page again.
    The continuation footer information will be stored in the template, and will automatically 'kick in' when your new letters go beyond a single page.

    Another advantage of doing it this way, as compared to using a section break, is that inserting a section break doesn't provide enough flexibility, in terms of a template.
    Try creating a similar template, but with a section break for the second page, to see what I mean.

    Gary

  7. #7
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Automatically include file-path in header/footer

    You can put the filename on the last page only of a document. Either in the header or footer of your document insert the If field (Insert | Field | Category: All and select If).
    You can also insert your own fields by using Ctrl F9 and then type the text between the field code brackets { }
    The if field syntax reads:
    If expression1 operator expression2 result-if-true result-if-false

    The following line says: If the current page number is equal to the total number of pages in the document then display the filename. I don't have a result-if-false as I do not want the filename displayed if the condition is not true.

    {if {page} = {numpages} {filename}}

    I'd love to take credit for this, but I read it somewhere!
    Cheers,
    Karen

  8. #8
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Automatically include file-path in header/footer

    Karen

    At least you can take credit for remembering it when it was needed.[img]/w3timages/icons/laugh.gif[/img]
    David Grugeon
    Brisbane Australia

  9. #9
    Lappenlocker
    Guest

    Re: Automatically include file-path in header/footer

    Very nice trick. Now, how do I add a field like this using VBA to create a footer with additional text? See sample code. All I can ever get is the field replacing the entire footer's text. This is a chunk of code that is used to toggle letterhead documents between printing to actual letterhead, or "faux" plain paper letterhead (the document's header/footer duplicates the real letterhead). I don't want to use the .selection method, as the user will see things happening on-screen.

  10. #10
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Automatically include file-path in header/footer

    Include the FILENAME field in an IF field.
    {IF {PAGE}={PAGENUM} {FILENAME}}

    Remember that the braces must be inserted using the Ctrl-F9 key combination or otherwise by Word. Typing them won't work.
    Charles Kyle Kenyon
    Madison, Wisconsin

  11. #11
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Sun Prairie, Wisconsin, Wisconsin, USA
    Posts
    2,049
    Thanks
    124
    Thanked 119 Times in 116 Posts

    Re: Automatically include file-path in header/footer

    Sorry, don't know the answer to your question because I can't decipher your code. (I'm too ignorant, nothing wrong with the way you write code.)

    One thing I did notice though is that you are putting it into the FirstPageHeaderFooter and I doubt that this is what you want.

    If you are constructing letterhead, you may also want to download http://www.addbalance.com/word/downl...headsystem.zip and take a look at it. It may give you some helpful ideas that aren't on topic for this posting.
    Charles Kyle Kenyon
    Madison, Wisconsin

  12. #12
    Lappenlocker
    Guest

    Re: Automatically include file-path in header/footer

    That isn't my problem. Using VBA, I want to add the field, along with additional text. Please see my sample code in the prior post.

  13. #13
    Lappenlocker
    Guest

    Re: Automatically include file-path in header/footer

    Regarding the (perceptive) comment on FooterFirstPage, I have a different footer on "faux" letterhead for the first page, and will need that field in case the letter is a single pager. The field will also be on the other footer, in case the letter is more than one page. I'll check out your link.

  14. #14
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Christchurch, New Zealand
    Posts
    250
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Automatically include file-path in header/footer

    Hi, well to get VBA to add text I would use the Selection object. If you turn screenupdating off, your user's shouldn't see the text being inserted into the footer.

    With regard to your text replacing what is currently in the footer, the following code inserts it before any text that is already in the footer.

    The code to insert the If field into the footer looks rather messy to me but you could probably tidy it up.

    Another way is to simply put your "faux" letterhead (including If field) into a formatted autotext entry or another Word document, and have your procedure either insert the autotext entry or insert the file.

    Sub InsertLetterHead()

    Application.ScreenUpdating = False

    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter

    Selection.TypeText Text:="Line 1, Part 1" & vbTab & "Line 1, Part 2" & vbCrLf & _
    "Line 2, Part 1" & vbTab & "Line 2, Part 2" & vbCrLf & _
    "Line 3, Part 1" & vbTab & "Line 3, Part 2" & vbCrLf & vbCrLf & vbTab

    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False
    Selection.TypeText Text:="if "
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False
    Selection.TypeText Text:="page"
    Selection.MoveRight Unit:=wdCharacter, Count:=2
    Selection.TypeText Text:=" = "
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False
    Selection.TypeText Text:="numpages"
    Selection.MoveRight Unit:=wdCharacter, Count:=2
    Selection.TypeText Text:=" "
    Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
    PreserveFormatting:=False
    Selection.TypeText Text:="filename"
    Selection.EndKey Unit:=wdLine

    Selection.HomeKey Unit:=wdLine, Extend:=wdExtend
    Selection.Fields.Update

    Selection.EndKey Unit:=wdLine
    Selection.TypeParagraph


    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    Application.ScreenRefresh
    Application.ScreenUpdating = True

    End Sub

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

    Re: Automatically include file-path in header/footer

    Hi Charles:
    You mean NUMPAGES, not PAGENUM, don't you?

Page 1 of 2 12 LastLast

Posting Permissions

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