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
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