Tranferring Text from Excel to a Header in Word

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi all,

I have a macro that exports a range of data and chart from excel to a word
template in the form of a jpeg.

Is it possible to take text entered in particular cell in the excel template
and copy it to a Ms Word Header ? e.g. say the name of someone..

I have the code for opening word and pasting the other data but accessing
the word header is where I fail !

Any help is much appreciated.


Michael
 
Hello Michael

I hope this help you


Sub insertData_In_WordHeader()
'Activate Microsoft Word xx.x Object Library
Dim WordApp As Word.Application
Dim WordDoc As Word.document

Set WordApp = New Word.Application
WordApp.Visible = True

Set WordDoc = WordApp.Documents.Open("C:\myDocument.doc")

With WordDoc.Sections(1)
..Headers(wdHeaderFooterPrimary).Range.Text = Range("A1")
..Headers(wdHeaderFooterPrimary).Range.Paragraphs.Alignment =
wdAlignParagraphCenter
End With
End Sub



Regards ,
michel
 

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

Back
Top