Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations John Tel on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Headers and Footers - Copy as Picture 1

Status
Not open for further replies.

Freemo

MIS
Oct 25, 2005
71
GB
Hello All

I'm trying to grab the Headers and Footers of Word documents and Save them as pictures. I have been trying out a bit of coding that i found on this wonderful forum.

The code i have been trying is:

Dim myWord As Word.Application
Dim myDoc As Word.Document

Set myWord = GetObject(, "Word.Application")
Set myDoc = myWord.ActiveDocument

myDoc.Select

With myDoc.Content
.WholeStory
.CopyAsPicture
End With

myDoc.Close False
myWord.Quit False
Set myDoc = Nothing
Set myWord = Nothing

SavePicture Image1.Picture, "c:\word.emf"

This coding does grab the document text and any pictures/Tables in it but not the headers and footers.

Any help would be appriciated.

Thank you.
 
You'll be talking about my code in thread222-372057 (just thought I'd reference it, since you leave a few vital bits out)

Unfortunately the trick I use there won't work to grab headers, footers AND the document body because you cannot select header/footer and document body at the same time ...

One potential method would be to use the technique to grab the header, the body and the footer as three seperate images and then stitch them back together
 
Hello Strongm

Sorry for not referencing the code to you as i've had it for a while and only just got round to looking at it. It is a lovely bit of coding you have developed there.

I have added the following to grab the header:

myDoc.ActiveWindow.View.SeekView = wdSeekCurrentPageHeader
myWord.Selection.HeaderFooter.Shapes.SelectAll
myDoc.Select
myWord.Selection.CopyAsPicture

This does seem to work for me. If you were developing for the same result, would you use this method or is there a simpler way.

Thanx
 
I think I'd do something like:

MyDoc.ActiveWindow.ActivePane.View.SeekView = SeekCurrentPageHeader
myWord.Selection.WholeStory
myWord.Selection.CopyAsPicture

but it's much the same thing
 
Thanx for that, have a star for the advice and for me forgetting to reference the code to you, as without your coding i would be completely stuck.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top