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 / January 2007

Tip: Looking for answers? Try searching our database.

How do I get the total number of graphics/pictures in a word doc?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Ryan Dunn - 26 Jan 2007 02:20 GMT
I'm writing a macro that iterates through a word document and operates on
each picture it finds.  I need to be able to find the total number of
pictures in the file to control the for loop.  I have successfully done this
with tables using ActiveDocument.Tables.Count, but there seems to be no such
variable for graphics.  Using Selection.GoTo one can jump to the next
graphic, so I know that word has graphics flagged, but I need to know how
many so I know when to stop.  Any ideas?

Thanks,
Ryan
Greg Maxey - 26 Jan 2007 03:04 GMT
Ryan,

Are you working with shapes in the shaperange or inline shapes (in line with
text)?

Sub Test()
MsgBox ActiveDocument.InlineShapes.Count
MsgBox ActiveDocument.Range.ShapeRange.Count
Dim oShape As Shape
For Each oShape In ActiveDocument.Range.ShapeRange
 MsgBox oShape.Type
Next
For Each oILS In ActiveDocument.Range.InlineShapes
 MsgBox oILS.Type
Next oILS
End Sub

Signature

Greg Maxey/Word MVP
See:
http://gregmaxey.mvps.org/word_tips.htm
For some helpful tips using Word.

> I'm writing a macro that iterates through a word document and
> operates on each picture it finds.  I need to be able to find the
[quoted text clipped - 7 lines]
> Thanks,
> Ryan
Ryan Dunn - 26 Jan 2007 04:53 GMT
I'm not sure, but I think that the pictures are inline with the text.  If the
cursor is to the left of the picture, when I press right, it selects the
picture, and another right button press moves the cursor to the right of the
picture.  The cursor is along the lower edge of the picture.  I appologize
for my ignorance on this issue, I'm just starting out with Word macros.  Are
those the only two types of graphics within a Word document?  The "or" in
your question implies only two options, but I want to be sure.

Thanks,
Ryan

> Ryan,
>
[quoted text clipped - 24 lines]
> > Thanks,
> > Ryan
Ryan Dunn - 26 Jan 2007 05:02 GMT
I mis-spoke,  when moving the cursor, the picture is not selected, but if I
hold down the shift key it is.  I'll try your suggestions to see what works.

Thanks again,
Ryan

> I'm not sure, but I think that the pictures are inline with the text.  If the
> cursor is to the left of the picture, when I press right, it selects the
[quoted text clipped - 35 lines]
> > > Thanks,
> > > Ryan
 
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.