Group:  Microsoft Word ยป microsoft.public.word.oleinterop
Thread: Does an office app that uses PIA&VSTO need any user privilede to r

Geek News

Does an office app that uses PIA&VSTO need any user privilede to r
tutu 10/9/2008 5:48:01 AM
I'm developing as a non-administrator user in my domain.
It's weird when I debug my app.
for instance,
--------
Word doc=null;
.....(opens the document)

for(int i=0;i<doc.Sentences.Count;i++){
object start = doc.Sentences[i].Start;
object end = doc.Sentences[i].End;

Word.Range rng = doc.Range(ref start, ref end);
rng.Select();
}
---------
I see doc.Sentences.Count=7, but when code runs next:
object start = doc.Sentences[i].Start;
It just throws an exception:
" The requested member of the collection does not exist. at
Microsoft.Office.Interop.Word.Sentences.get_Item(Int32 index)..."

But the document does have multiple sentences. Why does this happen?
Does PIA require administrator privilege as PIA interact with COM objects?
Please help. Thanks.

Re: Does an office app that uses PIA&VSTO need any user privilede to r
Cindy M. <C.Meister-C[ at ]hispeed.ch> 10/24/2008 10:46:26 AM
Hi =?Utf-8?B?dHV0dQ==?=,

[Quoted Text]
> Does PIA require administrator privilege as PIA interact with COM
objects?
>
No, that's certain. I'm not sure what's happening, here...

If you try something more like this:
Word.Range rng = doc.Sentences[i];
//Sentence object returns a range

Do you see anything different?

> It's weird when I debug my app.
> for instance,
> --------
> Word doc=null;
> .....(opens the document)
>
> for(int i=0;i<doc.Sentences.Count;i++){
> object start = doc.Sentences[i].Start;
> object end = doc.Sentences[i].End;
>
> Word.Range rng = doc.Range(ref start, ref end);
> rng.Select();
> }
> ---------
> I see doc.Sentences.Count=7, but when code runs next:
> object start = doc.Sentences[i].Start;
> It just throws an exception:
> " The requested member of the collection does not exist. at
> Microsoft.Office.Interop.Word.Sentences.get_Item(Int32 index)..."
>
> But the document does have multiple sentences. Why does this happen?
>


Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Jun 17 2005)
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 :-)

Home | Search | Terms | Imprint Contact
Newsgroups Reader - provided by WiredBox.Net