Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / September 2005

Tip: Looking for answers? Try searching our database.

How to wrap a image which is call from excel? Disable Object

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
teddy b - 31 Aug 2005 08:34 GMT
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
Jean-Guy Marcil - 31 Aug 2005 17:37 GMT
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 

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.