ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Setting up headers & footers in Word from Excel (https://www.excelbanter.com/excel-programming/388609-setting-up-headers-footers-word-excel.html)

Oggy

Setting up headers & footers in Word from Excel
 
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



All times are GMT +1. The time now is 11:40 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com