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 / August 2003

Tip: Looking for answers? Try searching our database.

Selecting inline picture from Word VBA

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
hmmm... - 29 Aug 2003 05:28 GMT
Hi,

Enhanced metafile produces a picture that floats.  In this post I call a
picture that does not float an "inline" picture.

Is there a way of selecting an inline picture from VBA?  The picture
originates from Excel.  It is copied/pasted using the following code.

   Selection.GoTo what:=wdGoToBookmark, Name:="the_chart_bookmark"
   exapp.Worksheets("Sheet1").ChartObjects(1).Chart.CopyPicture xlScreen,
xlPicture
   Selection.Paste

I tried recording a macro, but in record mode, I could not select the
picture with the mouse.  The only way I could select it in record mode was
to use arrow keys, and do a shift-arrow key back over the picture.  However,
that recorded code is:

   Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend

I want to directly reference the picture and select it.  Similar to the way
it can be done for enhanced metafile.

I do not want to do a PasteSpecial specifying enhanced metafile because the
picture floats over the text (I want an inline picture).  However, if I do a
PasteSpecial and specify enhanced metafile, then I can select with the mouse
during record mode, and I get the following code:

   ActiveDocument.Shapes("Picture 11").Select

Is there anyway I can reference and select an inline picture in a similar
way?

Thanks.
Helmut Weber - 29 Aug 2003 08:20 GMT
Hi,
how about that:
with activedocument
For i = 1 To .InlineShapes.Count
  .InlineShapes(i).Select
Next
End With
Greetings from Bavaria, Germany
Helmut Weber
hmmm... - 29 Aug 2003 14:58 GMT
Thanks.  However, potentially there could be more than one inline picture in
the document.  I want to select a particular one.  Is there a way to name
the inline picture when it is pasted, so that it can be directly referenced
at a later time?

> Hi,
> how about that:
[quoted text clipped - 5 lines]
> Greetings from Bavaria, Germany
> Helmut Weber
Helmut Weber - 30 Aug 2003 09:49 GMT
Hi You noname,
unfortunately, there seems to be no property "name" for
an inlineshape, whereas shapes may have names. (???)
However, before inserting an inlineshape, you may insert
a bookmark and give it a name, so that your inlineshape
is located immediately right of the bookmark, and can
thereby be referenced by:
ActiveDocument.Bookmarks("Marke7").Select
selection.expand
MsgBox Selection.InlineShapes.Count 'Test
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT4.0
 
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.