Word VBA >> Table and Picture in Word Header

by Takuon Soho » Thu, 29 Jul 2004 22:18:10 GMT

Using VBA, I insert a file with tab delimited
fields into a Word header and then use
"ConvertToTable" and it works fine.

Now I'd like to have a logo picture
ABOVE the table but it keeps putting
it INTO a cell of the table.

It seems as though the table insists
on taking up the entire space of the header
no matter what I do.

In VBA, How do you get a bmp logo to
appear in the header above the header table???

Thanks
Tak




Word VBA >> Table and Picture in Word Header

by Dave Lett » Fri, 30 Jul 2004 01:57:30 GMT


Hi Tak,

Have you tried inserting the logo first, then adding your file and coverting
that to a table? Also, if this doesn't work, what's your routine look like?
That is, can you post what you're using?

Dave








Word VBA >> Table and Picture in Word Header

by James Pannozzi » Fri, 30 Jul 2004 02:21:50 GMT

Tried it both ways but I might have messed up the wdHeaderFooterFirstPage
settings when
I put the logo first.

I would probably want a blank line or two after the logo and before the
header table starts.

Does this look right?

' Add header bitmap to upper left corner area of header (8,5)
.Headers(wdHeaderFooterFirstPage).Shapes.AddPicture "H:\StrucOne\CGLogo.bmp"
, False, True, 8,5,380,90

Set myrange =
objWord.ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range
.Headers(wdHeaderFooterFirstPage).Range.Collapse wdCollapseEnd

' Insert Tab Delimited File and Convert to Table
.Headers(wdHeaderFooterFirstPage).Range.InsertFile "H:\StrucOne\header.txt"
.Headers(wdHeaderFooterFirstPage).Range.Collapse wdCollapseEnd
.Headers(wdHeaderFooterFirstPage).Range.Select
objWord.Selection.ConvertToTable wdSeparateByTabs

Thanks
Takuon Soho
(aka Jimserac, aka James Pannozzi)



coverting
like?






Table and Picture in Word Header

by Dave Lett » Fri, 30 Jul 2004 02:42:48 GMT

Hi James,

I don't use floating pictures (I prefer inlineshapes), so here's what I've
come up with:

Dim myrange As Range
With ActiveDocument.Sections(1)
Set myrange = .Headers(wdHeaderFooterFirstPage).Range
.Range.Fields.Add _
Range:=myrange, _
Type:=wdFieldIncludePicture, _
Text:="C:\\test\\test.gif", _
Preserveformatting:=True
With myrange
.Collapse Direction:=wdCollapseEnd
.InsertFile "C:\test\test.txt"
.End =
ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range.End
.ConvertToTable Separator:=wdSeparateByTabs
End With
End With

HTH,
Dave



"H:\StrucOne\CGLogo.bmp"
"H:\StrucOne\header.txt"








Table and Picture in Word Header

by James Pannozzi » Fri, 30 Jul 2004 02:57:00 GMT

K, InLineShapes.

I 'll give this a try.

Thanks again for the assitance
and for your numerous other posts which have helped me on
other Word VBA stuff too.

Jim

"Dave Lett" < XXXX@XXXXX.COM > wrote in message
news:O72# XXXX@XXXXX.COM ...
wdHeaderFooterFirstPage
objWord.ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range




Table and Picture in Word Header

by James Pannozzi » Sat, 31 Jul 2004 00:19:07 GMT

t Puts the Bitmap in OK
but I get a syntax error on the
line that says

".End ="

Analyzing it now.

Thanks
Jim

"Dave Lett" < XXXX@XXXXX.COM > wrote in message
news:O72# XXXX@XXXXX.COM ...
wdHeaderFooterFirstPage
objWord.ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range




Table and Picture in Word Header

by James Pannozzi » Sat, 31 Jul 2004 00:52:07 GMT

ep, that worked.

You had to get at the range of the last inserted object which was the text
and you did it.

I initially got a syntax error because of a mistype.

Thanks Again
Jim

"Dave Lett" < XXXX@XXXXX.COM > wrote in message
news:O72# XXXX@XXXXX.COM ...
wdHeaderFooterFirstPage
objWord.ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage).Range




Similar Threads

1. Add Picture in Word 2K to Header with Table

Hi,

I am trying to add a Logo to an Header in an template. Positioning with 
.Left and .Right works fine. But not when there is a Table in the Header. 
Then Word does not use the RelativeHorizontal(&Vertical)PositionPage 
correctly. With an table in the Header, Word will position the Picture 
against the upper left corner of the Table. And I am not allowed to remove 
the table...
Is there a work-around?

Thanks

PS: i use the following code (i removed the part for the different Header 
types and the Section part for your convenience...)

Set myShape = mySection.Headers(wdHeaderFooterPrimary).Shapes.AddPicture( _
 FileName:=strLogoFullName)
                
With myShape
   .LockAspectRatio = True
   .ZOrder msoSendBehindText
   .RelativeHorizontalPosition = wdRelativeHorizontalPositionPage
   .RelativeVerticalPosition = wdRelativeHorizontalPositionPage
   .Left = CentimetersToPoints(1)
   .Top = CentimetersToPoints(1)
   .Width = CentimetersToPoints(5)
End with          

2. Insert picture into a table in header - MS Word&VBA

3. Need to link topic headers in picture to topic header in word doc

I am trying to figure out how to take a Windows Metafile picture in my word 
document and link to the corresponding topic header within the same document.

4. picture in a Word header - Word VBA

5. microsoft word 2007 pictures overiding other pictures and word art

I am having a few issues with using word to enter client info for a 
callcentre. 
I will enter a required logo at the top of the page, and then through-out 
the doc I will add a few different images OR insert word art with a title/s. 
Every so often I will come back to the doc ( maybe 2 or 3 days later) and 
the picture or title has overrun all the other pictures or titles. 

I am editing and revamping client notes in a callcentre and save the docs 
through web filter in order to run through our created software. There is 
about 300 +/- docs and I am experiencing this problem with about 20-30 docs 
as of late. 

Sometimes it will occur after a week or so, I recall once I saved a map of 
nz on one doc and the next day a client title on a different doc had a 
squeshed map of nz in its place. - I had to re -enter the title - very time 
consuming when it happens to all my pictures or titles. 

Any clues ? 

6. Split table and copy a Table Header between both table - Word VBA

7. How do I setup a repeating table header in Word that marks tab

8. Repeating header rows in table using Word 2000 field codes