Table and Picture in Word Header

T

Takuon Soho

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
 
D

Dave Lett

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
 
J

James Pannozzi

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)
 
D

Dave Lett

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
 
J

James Pannozzi

OK, 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
 
J

James Pannozzi

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

".End ="

Analyzing it now.

Thanks
Jim
 
J

James Pannozzi

Yep, 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
 

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

Top