Setting up headers & footers in Word from Excel

O

Oggy

Hi, i am trying to control Word from a Excel macro so that i can
create a document from infomation on the spreadsheet. My problem is i
am having problems setting up the headers and footers. Please can you
advise me on the following code,

Thanks Oggy




' Send commands to Word
Dim wrdApp As Word.Application
Dim doc As Word.Document
Dim rngDoc As Word.Range


Set wrdApp = CreateObject("Word.Application")
wrdApp.Visible = True
Set doc = wrdApp.Documents.Add ' create a new document

Set rngDoc = doc.Content

Dim HdFt As HeaderFooter
Set HdFt = doc.Sections(1).Headers(wdHeaderFooterFirstPage)



With WordApp

With HdFt
.Text = "Left side" & vbTab & "Center" & vbTab & "right side"
End With



With rngDoc
.Font.Name = "Times New Roman"
.Font.Size = 10
.Font.Bold = False
.Font.Italic = False
.ParagraphFormat.Alignment = 1
.Text = "QUOTATION" & vbCr
End With





End With

End Sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top