UnauthorizedAccessException at shape.Select

H

Herr Berrt

I get an UnauthorizedAccessException when I try to select a shape:

Word.Shapes lShapesMain = VADot.AppWord.ActiveDocument.Shapes;
object lItem2 = (object)"Rectangle 65";
Word.Shape shape = lShapesMain.get_Item(ref lItem2);
shape.Select( ref mTypeMissing );

Has anybody any idea?

Thx
Herr Berrt
 
C

Cindy M -WordMVP-

Hi =?Utf-8?B?SGVyciBCZXJydA==?=,
I get an UnauthorizedAccessException when I try to select a shape:

Word.Shapes lShapesMain = VADot.AppWord.ActiveDocument.Shapes;
object lItem2 = (object)"Rectangle 65";
Word.Shape shape = lShapesMain.get_Item(ref lItem2);
shape.Select( ref mTypeMissing );
Seeing as how you're using an "advanced" language (not a VB dialect), I'm
surprised you use ActiveDocument, rather than creating a Word.Document
object variable and working from that. Not said that this is the problem,
but I'd certainly make that change, first.

Then, are you certain a Shape of this name actually exists in that
document? Shape names that Word assigns can be extremely volatile - Word
will change them at the drop of a hat.

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 :)
 
H

Herr Berrt

Yes, its sure, that this shape exists, otherwise I get another exception
(like "object doesnt exits" or similar).

Herr Berrt
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top