View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
Alex St-Pierre Alex St-Pierre is offline
external usenet poster
 
Posts: 169
Default 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