PDA

View Full Version : Solved: Header/Footer - different first page?



babsiee
01-30-2012, 08:14 AM
Hi Everybody!

I have some trouble with my macro. I am totally new in learning macro's and all and I really like it. But right now I am stuck :( Hope you guys can help.

Below you see my macro so far. What I would like to do now is to have a different header and footer on the first page. I have found a Public Function for that. But how do I include the public function into my macro???

Because I am a super newbie to VBA and macro's I cannot figure it out.

I hope someone can help me. Thank you so much in advance.

Many kind regards,
Babete

------------------------------------
My macro:
---------------------------------------

Sub titelmacro()
'
' titelmacro 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:= _
"logo.jpg", LinkToFile:= _
False, SaveWithDocument:=True

WordBasic.ViewFooterOnly
' ActiveDocument.AttachedTemplate.BuildingBlockEntries(" Leeg").Insert Where _
:=Selection.Range, RichText:=True
Selection.InlineShapes.AddPicture fileName:= _
"logo.jpg", LinkToFile:= _
False, SaveWithDocument:=True
Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
Selection.MoveDown Unit:=wdLine, Count:=1
Selection.MoveUp Unit:=wdLine, Count:=1
Selection.TypeParagraph
Selection.TypeParagraph
Selection.TypeText Text:= _
"Tekst onderaan pagina."

Selection.MoveLeft Unit:=wdCharacter, Count:=322, Extend:=wdExtend
Selection.Font.Name = "Arial"
Selection.Font.Size = 8

End Sub

----------------
The public function I have found
--------------------

Public Function ChangeHeadersAndFooters()


For i = 1 To ActiveDocument.Sections.Count
With ActiveDocument.Sections(i)
.Headers(wdHeaderFooterPrimary).LinkToPrevious = True
.Headers(wdHeaderFooterPrimary).Range.Text = "Koptekst vanaf pagina 2"
.Footers(wdHeaderFooterPrimary).Range.Text = "Voettekst vanaf pagina 2"
End With
Next i

ActiveDocument.Sections(1).PageSetup.DifferentFirstPageHeaderFooter = True
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range.Text = "test"


'With ActiveDocument.Sections(1)
' .PageSetup.DifferentFirstPageHeaderFooter = True
' .Headers(wdHeaderFooterFirstPage).LinkToPrevious = False
' .Headers(wdHeaderFooterFirstPage).Range.Text = "eerste pagina koptekst"
' .Footers(wdHeaderFooterFirstPage).Range.Text = "eerste pagina voettekst"
'End With

Selection.HomeKey wdStory

babsiee
02-02-2012, 03:31 AM
Or maybe there is someone who knows how to solve the problem and how I can incorporate another kind of code into my macro? I tried to record my macro by changing the header and footer but it does not work. While recording I cannot click on 'make the first page header and footer different then the other page'.

Hope someone can help :)

fumei
02-03-2012, 08:31 PM
Under PageSetup you can set it to be Different First Page. No macro required.