![]() |
|
#1
|
|||
|
|||
![]()
Hi Every one,
we are looking solution here for the header placement with page number through VBA. Can anyone help us to resolve this issue? left Side Page we want a title with the Page number right side Page we want Author's name with the Page number attaching a Word file for your ref. |
#2
|
|||
|
|||
![]()
Why do you need VBA for this?
Just use the Title and Author content controls that you find under Insert | Quick Parts | Document Property on both the front page and in the header. |
#3
|
|||
|
|||
![]()
Thank you for your suggestion.
we have tried to use Quick Part as well. but in every file we do the manual setting and its taking time to add every time. we have 1000+plus file and we want minimum manual work to be added header. |
#4
|
|||
|
|||
![]()
In your document template, create a building block entry of the Primary Page Header content (minus the final paragraph mark). Name it "HPP"
Create a building block entry of the Even Page Header content (minus the final paragraph mark). Name it "HEP" Run this macro: Code:
Sub ScratchMacro() 'A basic Word Macro coded by Gregory K. Maxey Dim oHF As HeaderFooter Dim oRng As Range For Each oHF In ActiveDocument.Sections(1).Headers Set oRng = oHF.Range Select Case oHF.Index Case wdHeaderFooterPrimary oRng.Text = vbNullString oRng.Collapse wdCollapseStart ActiveDocument.AttachedTemplate.BuildingBlockEntries("HPP").Insert oRng Case wdHeaderFooterEvenPages oRng.Text = vbNullString oRng.Collapse wdCollapseStart ActiveDocument.AttachedTemplate.BuildingBlockEntries("HEP").Insert oRng End Select Next lbl_Exit: Exit Sub End Sub |
![]() |
Tags |
header numbers, header page numbering, header template |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
![]() |
webgal318 | Word | 4 | 06-22-2020 06:40 PM |
Don't want page number or date in footer on first page, do want graphic in header. | dianahbr | Word | 2 | 02-23-2018 09:25 AM |
![]() |
rimutaka | Word | 4 | 06-01-2016 08:30 PM |
![]() |
wpryan | Word VBA | 3 | 07-17-2015 07:04 AM |
![]() |
atitool | Word | 1 | 11-06-2014 06:42 AM |