ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   add footer page name in word using excel (https://www.excelbanter.com/excel-programming/325452-add-footer-page-name-word-using-excel.html)

Alex St-Pierre

add footer page name in word using excel
 
Hello,
I use excel vba to copy a lot of word file in different folder. I would like
to customize each word document by inserting the name of each person in the
footer page. Does anyone know how can I do that? (I'm not famillar with
word vba)
Thanks!
example:
workbook.open ("test.doc")
workbooks("test.doc").insert.foot.page(1) = "..."
workbook.close (true)
--
Alex St-Pierre

Gareth Roberts

add footer page name in word using excel
 
Hi,

I would suggest you open up Word and have a bit of a play recording macros
and editing there. When you're finally happy with it just copy it all to
Excel. Personally I find Word VBA a bit messy with all its sections, and
things.... not like good old straightforward Excel. However, if this helps:

Dim oWord As Word.Application
Dim myDoc As Document
Set oWord = GetObject("", "Word.Application")
Set myDoc = oWord.Documents.Open
'use 1 instead of wdHeaderFooterPrimary if you use late binding
myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange.Text = "I am a
footer"

rest of your code... myDoc.save, myDoc.close etc.

If it suits your purposes its far easy to make a reference to the Microsft
Word Object Library in your Excel project - tehn you can use early binding.
Otherwise you will have to change Word.Application and DOcument in the
declarations to Object

HTH,
Gareth

"Alex St-Pierre" wrote in message
...
Hello,
I use excel vba to copy a lot of word file in different folder. I would

like
to customize each word document by inserting the name of each person in

the
footer page. Does anyone know how can I do that? (I'm not famillar with
word vba)
Thanks!
example:
workbook.open ("test.doc")
workbooks("test.doc").insert.foot.page(1) = "..."
workbook.close (true)
--
Alex St-Pierre




Alex St-Pierre

add footer page name in word using excel
 
Hi,
I have copy the codes but I can't execute.
I want to open "C:\test.doc" document and add a footer.

Dim oWord As Word.Application 'not working
Dim myDoc As Document 'not working
Set oWord = GetObject("", "Word.Application") 'ok
Set myDoc = oWord.Documents.Open 'not working
I tried: set myDoc = oWord.Documents.open ("C:\test.doc") but all jammed..
Any idea..?
Thanks,
Alex

"Gareth Roberts" wrote:

Hi,

I would suggest you open up Word and have a bit of a play recording macros
and editing there. When you're finally happy with it just copy it all to
Excel. Personally I find Word VBA a bit messy with all its sections, and
things.... not like good old straightforward Excel. However, if this helps:

Dim oWord As Word.Application
Dim myDoc As Document
Set oWord = GetObject("", "Word.Application")
Set myDoc = oWord.Documents.Open
'use 1 instead of wdHeaderFooterPrimary if you use late binding
myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange.Text = "I am a
footer"

rest of your code... myDoc.save, myDoc.close etc.

If it suits your purposes its far easy to make a reference to the Microsft
Word Object Library in your Excel project - tehn you can use early binding.
Otherwise you will have to change Word.Application and DOcument in the
declarations to Object

HTH,
Gareth

"Alex St-Pierre" wrote in message
...
Hello,
I use excel vba to copy a lot of word file in different folder. I would

like
to customize each word document by inserting the name of each person in

the
footer page. Does anyone know how can I do that? (I'm not famillar with
word vba)
Thanks!
example:
workbook.open ("test.doc")
workbooks("test.doc").insert.foot.page(1) = "..."
workbook.close (true)
--
Alex St-Pierre





Gareth Roberts

add footer page name in word using excel
 
Hi,

This worked for me:

Sub PlaceTextInFooter()

Dim oWord As Object 'Word.Application
Dim myDoc As Object 'Document
Set oWord = GetObject("", "Word.Application")
Set myDoc = oWord.Documents.Open("c:\test.doc")
'use 1 instead of wdHeaderFooterPrimary if you use late binding
myDoc.Sections(1).Footers(1).Range.Text = "I am a footer "
myDoc.Save

myDoc.Close
Set oWord = Nothing
Set myDoc = Nothing

End Sub

Please take note of what I wrote in the previous email regarding making a
reference to MS Word in your project - if you don't do that you have to use
"late binding" - as I have above. I think you are far better writing this
code in Word first before moving it to Excel.

HTH,
Gareth


"Alex St-Pierre" wrote in message
...
Hi,
I have copy the codes but I can't execute.
I want to open "C:\test.doc" document and add a footer.

Dim oWord As Word.Application 'not working
Dim myDoc As Document 'not working
Set oWord = GetObject("", "Word.Application") 'ok
Set myDoc = oWord.Documents.Open 'not working
I tried: set myDoc = oWord.Documents.open ("C:\test.doc") but all jammed..
Any idea..?
Thanks,
Alex

"Gareth Roberts" wrote:

Hi,

I would suggest you open up Word and have a bit of a play recording

macros
and editing there. When you're finally happy with it just copy it all to
Excel. Personally I find Word VBA a bit messy with all its sections, and
things.... not like good old straightforward Excel. However, if this

helps:

Dim oWord As Word.Application
Dim myDoc As Document
Set oWord = GetObject("", "Word.Application")
Set myDoc = oWord.Documents.Open
'use 1 instead of wdHeaderFooterPrimary if you use late binding
myDoc.Sections(1).Footers(wdHeaderFooterPrimary).R ange.Text = "I am a
footer"

rest of your code... myDoc.save, myDoc.close etc.

If it suits your purposes its far easy to make a reference to the

Microsft
Word Object Library in your Excel project - tehn you can use early

binding.
Otherwise you will have to change Word.Application and DOcument in the
declarations to Object

HTH,
Gareth

"Alex St-Pierre" wrote in

message
...
Hello,
I use excel vba to copy a lot of word file in different folder. I

would
like
to customize each word document by inserting the name of each person

in
the
footer page. Does anyone know how can I do that? (I'm not famillar

with
word vba)
Thanks!
example:
workbook.open ("test.doc")
workbooks("test.doc").insert.foot.page(1) = "..."
workbook.close (true)
--
Alex St-Pierre








All times are GMT +1. The time now is 03:18 AM.

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