1
votes

Q1:

Actually, i have to insert the page id like <a id="page_1"/>, <a id="page_2"/>... n in end of the page, so i have the below code for Insert Page numbers in each page.

Sub pagenosadd()
With ActiveDocument.Sections(1)
 .Footers(wdHeaderFooterPrimary).PageNumbers.add _
 PageNumberAlignment:=wdAlignPageNumberLeft, _
 FirstPage:=True
 End With
End Sub

After run the macro, i have to find the page numbers and replace with <a id="page_1"/>, <a id="page_2"/>...<a id="page_n"/>

How to find and replace the footers?

Q2: How to Convert the footers to normal text in same page?

Q3: Or is it possible to directly add footers as <a id="page_1">...n and convert as text on the page?

It will be really very helpful to increase my skills?

EDIT:

Now, I have tried the below code for inserting footer as <a id="page_1"/>...n

Sub addfootaspage()

Dim k As Integer

For k = 0 To ActiveDocument.Sections.Count
k = k + 1
    With ActiveDocument.Sections(k)
        .Footers(wdHeaderFooterPrimary).Range.Text = "<a id=""page_" & k & "> "
    End With
Next k
End Sub

But inserted as <a id="page_1"/> to all the page, it's not counting the values.

1

1 Answers

0
votes

take look at the following link or link

This example adds a page number to the primary footer in the first section of the active document.

With ActiveDocument.Sections(1) 
 .Footers(wdHeaderFooterPrimary).PageNumbers.Add _ 
 PageNumberAlignment:=wdAlignPageNumberLeft, _ 
 FirstPage:=True 
End With

This example creates and formats page numbers in the header for the active document.

Set myPgNum = ActiveDocument.Sections(1) _ 
 .Headers(wdHeaderFooterPrimary) _ 
 .PageNumbers.Add(PageNumberAlignment:= _ 
 wdAlignPageNumberCenter, FirstPage:= True) 
myPgNum.Select 
With Selection.Range 
 .Italic = True 
 .Bold = True 
End With