FranciscoLopez
Thu Aug 25 10:15:02 CDT 2005
It fails with Word Xp (2002) and Word 2003.
You must create a word document and insert an autoshape and an inlineshape
as an ActiveX Control (CalendarControl for example- insert- Object -Calendar
control)
This is the code in C#: (It happens the same in any other language)
object missing = System.Reflection.Missing.Value;
Word.ApplicationClass oWordApp = new Word.ApplicationClass();
Word.Document oWordDoc = oWordApp.Documents.Open(ref fileName,ref
missing,ref readOnly, ref missing, ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing, ref missing, ref isVisible);
int count=oWordDoc.InlineShapes.Count; //This will return 1.
Word.InlineShape shape= oWordDoc.InlineShapes.Item(1); //This will thow the
exception: The requested member of the collection does not exist.
Word.InlineShape shape2= oWordDoc.InlineShapes.Item(2); //This will work.
I think that the first Item sentence should have been worked, because Count
return 1 and it is the first inlineshape, But I must retrieve the calendar
control with Item(2).
How can I know what are the indexs of the items that are inlineShapes?
"Cindy M -WordMVP-" wrote:
> Hi =?Utf-8?B?RnJhbmNpc2NvIExvcGV6?=,
>
> You can't be using just InlineShapes or Shapes. These have to be the property of
> some object (such as Document or Range or Selection). What code are you using,
> more exactly? And in which version of Word?
>
> > I'm writing an application that make some operations with some objects stored
> > as inlineshapes in a word document, but when I insert an Autoshape in Word
> > XP, and an activeX object (CalendarControl) as an inline object, then
> > InlineShapes.Count returns 1 (I guess because of the calendar control), but
> > when I try to get the item with InlineShapes.Item(1), it throws an exception,
> > saying that the item is out of range.
> >
> > I must get the CalendarControl with InlineShapes.Item(2), despite that the
> > count property returned that there are only 1 element (count returned 1).
> >
> > When I check Shapes.Count it returns 1 as well. (I guess because of the
> > autoshape)
> > I must get the AutoShape with Shapes.Item(1);
> >
> >
> > So it seems that there are 2 collections (InlineShapes and Shapes) that
> > share the indexes.
> >
> > Is this a bug?
> >
> > How could I now which index is a InlineShape and which one is a Shape? in
> > order to not to get the exception when I use the .Item(index) member?
> >
>
> Cindy Meister
> INTER-Solutions, Switzerland
>
http://homepage.swissonline.ch/cindymeister (last update Jun 8 2004)
>
http://www.word.mvps.org
>
> This reply is posted in the Newsgroup; please post any follow question or reply
> in the newsgroup and not by e-mail :-)
>
>