1.

Solve : create vbs to add text to start of each page of word?

Answer»

Can some HELP me change the FOLLOW vbs script to add the text "start" and "end" to each PAGE of an existing multiple page doc.

the text ALSO formated into white colour



strDocument = "c:\document.doc"

Set objWord = CreateObject("Word.Application")
objWord.Visible = False
Set objDoc = objWord.Documents.Open(strDocument)
Set objSelection = objWord.Selection

intLine = 1
intTotal = objDoc.Paragraphs.Count

For i = 1 To intTotal
If i > 8 Then
strPrepend = "| abc | " & intLine & " | L "
startRange = objDoc.Paragraphs(i).Range.Start
endRange = objDoc.Paragraphs(i).Range.End
Set tRange = objDoc.Range(startRange, endRange)
strLine = tRange.Text
strLine = Left(strLine, Len(strLine) - 1)
If strLine = "" Then
tRange.Text = strPrepend & vbCrLf
Else
tRange.Text = strPrepend & strLine & vbCrLf
End If
intLine = intLine + 1
End If
Next

objDoc.Save
objWord.Quit



Discussion

No Comment Found