Need help.
My image will call out from excel file then post it to the header of document.
The image is sit inside header Frame and table.
How to wrap it using vba? I'm trying Application.Options.PrintDrawingObjects
= False but not working. It's work only after i wrap it manualy on the image.
Below is my script:
With wb.Sheets(2)
LastRow = .Range("A65536").End(xlUp).Row
For z = 2 To LastRow
If (.Range("A" & z).Text) = "1" Then
'Check Image
If Len(Dir("C:\" & (.Range("A" & z).Text))) > 0 Then
FName = (.Range("A & z).Text)
With ActiveDocument.Sections(1).Headers
(wdHeaderFooterFirstPage).Range.Tables(1).Cell(1, 1).Range
.Delete
.InlineShapes.AddPicture FileName:="C:\" & FName,
LinkToFile:=False
End With
End If
End If
Next z
End With
Thanks.
Regards,
teddy
teddy b via OfficeKB.com was telling us:
teddy b via OfficeKB.com nous racontait que :
> Need help.
>
[quoted text clipped - 24 lines]
> Next z
> End With
You could do it like this:
'_______________________________________
Sub test1()
Dim myInlineShape As InlineShape
Dim myShape As Shape
With ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage) _
.Range.Tables(1).Cell(1, 1).Range
.Delete
Set myInlineShape = .InlineShapes _
.AddPicture(FileName:="C:\" & FName, LinkToFile:=False)
With myInlineShape
Set myShape = .ConvertToShape
With myShape
.WrapFormat.Type = wdWrapSquare
End With
End With
End With
End Sub
'_______________________________________
But, if you are going to end up with a Shape, why use an InlineShape in the
first place?
Compare:
'_______________________________________
Sub test2()
Dim myInlineShape As InlineShape
Dim myShape As Shape
With ActiveDocument.Sections(1).Headers(wdHeaderFooterFirstPage) _
.Range.Tables(1).Cell(1, 1).Range
.Delete
Set myShape = ActiveDocument.Shapes _
.AddPicture(FileName:="C:\" & FName, _
LinkToFile:=False, Anchor:=.Paragraphs(1).Range)
With myShape
.WrapFormat.Type = wdWrapSquare
End With
End With
End Sub
'_______________________________________

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org
teddy b - 08 Sep 2005 11:09 GMT
Thanks Jean. It's work.
What is the impact for these 2 methods?
>teddy b via OfficeKB.com was telling us:
>teddy b via OfficeKB.com nous racontait que :
[quoted text clipped - 49 lines]
>End Sub
>'_______________________________________
Jean-Guy Marcil - 08 Sep 2005 14:00 GMT
teddy b via OfficeKB.com was telling us:
teddy b via OfficeKB.com nous racontait que :
> Thanks Jean. It's work.
>
> What is the impact for these 2 methods?
One inserts an inline shape and then converts it to a floating shape (as you
were doing in your first post), the other inserts a floating shape directly.

Signature
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
jmarcilREMOVE@CAPSsympatico.caTHISTOO
Word MVP site: http://www.word.mvps.org