none
Word Macro's RRS feed

  • Question

  • Hello guys,

     

    i go 2 pages named 'page 1'. i apply the header and footer both 1 picture. then i get on both the pages the header and the footer the pictures, i only want the header and footer(pictures) on the first page, but i keep on getting 4 pictures because word thinks page 1 is 2 pages.... can anyone remove the second header and footer out of my scipt??

     

    Thanks,

     

    Eddy

     

    Sub test1()
    '
    ' test1 Macro
    '
    '
        If ActiveWindow.View.SplitSpecial <> wdPaneNone Then
            ActiveWindow.Panes(2).Close
        End If
        If ActiveWindow.ActivePane.View.Type = wdNormalView Or ActiveWindow. _
            ActivePane.View.Type = wdOutlineView Then
            ActiveWindow.ActivePane.View.Type = wdPrintView
        End If
        ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
        Selection.InlineShapes.AddPicture FileName:= _
            "C:\Users\eddy\Desktop\Project macro\Back-up\phylax-logo.gif", LinkToFile _
            :=False, SaveWithDocument:=True
        If Selection.HeaderFooter.IsHeader = True Then
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageFooter
        Else
            ActiveWindow.ActivePane.View.SeekView = wdSeekCurrentPageHeader
        End If
        Selection.InlineShapes.AddPicture FileName:= _
            "C:\Users\eddy\Desktop\Project macro\tkst.JPG", LinkToFile:=False, _
            SaveWithDocument:=True
        Selection.Delete Unit:=wdCharacter, Count:=1
        Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
        Selection.Delete Unit:=wdCharacter, Count:=1
        ActiveWindow.ActivePane.VerticalPercentScrolled = 7
        Selection.HeaderFooter.LinkToPrevious = Not Selection.HeaderFooter. _
            LinkToPrevious
        Selection.Delete Unit:=wdCharacter, Count:=1
        ActiveWindow.ActivePane.VerticalPercentScrolled = 0
        ActiveWindow.ActivePane.View.SeekView = wdSeekMainDocument
    End Sub



    • Edited by Beginnerword Wednesday, September 14, 2011 12:25 PM
    • Moved by Max Meng Thursday, September 15, 2011 2:46 PM (From:Word IT Pro Discussions)
    Wednesday, September 14, 2011 10:37 AM

All replies

  • Sub InsertInFirstPageHeader()
        Dim rng As word.Range
        Dim doc As word.Document
        
        Set doc = ActiveDocument
        doc.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
        Set rng = doc.Sections(1).Headers(wdHeaderFooterFirstPage).Range
        rng.InlineShapes.AddPicture FileName:= _
            "C:\Users\eddy\Desktop\Project macro\tkst.JPG", LinkToFile:=False, _
            SaveWithDocument:=True, Range:=rng
    End Sub
    
    


    Hi "Beginner"

    I'm not certain I'm understanding everything about your scenario, but see if this approach gets you any closer:

     


    Cindy Meister, VSTO/Word MVP
    Friday, September 16, 2011 7:16 AM
    Moderator