Consulting

Results 1 to 5 of 5

Thread: VBA Coding commands

  1. #1
    VBAX Regular
    Joined
    Nov 2004
    Posts
    74
    Location

    VBA Coding commands

    Hello, I have a template that on opening brings up a dialog box giving options.
    Depending on the option selected the macro outputs the required footer.
    The problem is that I only want the footer to be output on the front page. At the moment the code is going to the current page (2 maybe 3) and outputting, to all sheets except the front sheet.
    I am currently using this code:
    [VBA]Select Case True

    Case Is = Me.optBrighton
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Selection.MoveDown Unit:=wdLine, Count:=9
    Selection.Range.Text = "67 Old kent Road DX1111 London 1 Registered in England No 11111"
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    With Selection
    .Font.Size = 8
    .Paragraphs.Alignment = wdAlignParagraphLeft
    End With
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.TypeParagraph
    Selection.Range.Text = "Tel: 0161 585265 Fax:0161 555555 Email: info@test.co.uk Registered Office: Old kent road, London, UK"
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    With Selection
    .Font.Size = 8
    .Paragraphs.Alignment = wdAlignParagraphLeft
    End With
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument

    Case Is = Me.OptManchester
    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
    Selection.MoveDown Unit:=wdLine, Count:=9
    Selection.Range.Text = "Picadilly, London L56 8RF Registered in England No 22222"
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    With Selection
    .Font.Size = 8
    .Paragraphs.Alignment = wdAlignParagraphLeft
    End With
    Selection.MoveDown Unit:=wdLine, Count:=1
    Selection.TypeParagraph
    Selection.Range.Text = "Tel: 0161 855559 Fax:0178 3333333 Email: info@test.co.uk Registered Office: old kent road, London, UK"
    Selection.EndKey Unit:=wdLine, Extend:=wdExtend
    With Selection
    .Font.Size = 8
    .Paragraphs.Alignment = wdAlignParagraphLeft
    End With
    ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument


    End Select[/VBA]

    PLEASE HELP!

  2. #2
    Moderator VBAX Master Tommy's Avatar
    Joined
    May 2004
    Location
    Houston, TX
    Posts
    1,184
    Location
    Hi newk,
    Try this instead of using seek current page footer use seek first page footer.

    ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter

    ActiveWindow.ActivePane.View.SeekView = wdSeekFirstPageFooter

    HTH
    Tommy

  3. #3
    VBAX Regular
    Joined
    Nov 2004
    Posts
    74
    Location
    Thanks Tommy thats great!

  4. #4
    VBAX Wizard
    Joined
    May 2004
    Posts
    6,713
    Location
    Assuming you only want the footer on the first page - and be careful if you are using other Sections - you can explicitly set the text without going into Views.

    [vba]Select Case True
    Case Is = Me.optBrighton
    With Selection
    With .PageSetup
    .SectionStart = wdSectionNewPage
    .OddAndEvenPagesHeaderFooter = False
    .DifferentFirstPageHeaderFooter = True
    End With
    With .Sections(1).Footers
    .Item(1).Range.Text = "67 Old kent Road DX1111 " & _
    London 1 Registered in England No 11111"
    .Item(2) = ""
    .Item(3) = ""
    End With
    etc etc etc[/vba]

  5. #5
    Administrator
    VP-Knowledge Base
    VBAX Guru MOS MASTER's Avatar
    Joined
    Apr 2005
    Location
    Breda, The Netherlands
    Posts
    3,281
    Location
    Quote Originally Posted by newk
    Thanks Tommy thats great!
    Hi and Welcome to VBAX!

    Glad to see your problem is fixed!
    Would you be so kind to mark your thread solved?

    To improve your code try Fumei's suggestion. That is more reliable, faster and error resistent then going into views which is also slower.

    _________
    Groetjes,

    Joost Verdaasdonk
    M.O.S. Master

    Mark your thread solved, when it has been, by hitting the Thread Tools dropdown at the top of the thread.
    (I don't answer questions asked through E-mail or PM's)

Posting Permissions

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