command failed on activating an inline shape.

R

rob

I am having trouble with inlineshape.item(i).activate command. this
command works fine with most inlineshapes, but we have some word
picture.8 that will not/cannot be activated on certain machines. We
have word xp 2002 installed on the affected machines. why would this
command activate the affected picture on some machines and not on
others with word 2002 in stalled on them.
I get the error command failed. Not that word vba recognises this
picture as an inline shape to start with.

see sample code

For i = 1 To AInlineShapes.Count
On Error Resume Next

AInlineShapes.Item(i).Activate

Select Case Err.Number
Case 0
MsgBox "INline shape successfully activated "
activedocument.close
Case 4605, 5892
MsgBox "handled error " & Err.Description
Case Else
MsgBox "Unhandled error " & Err.Description

End Select

Next
 
P

Peter Hewett

Hi rob

I'm not sure how you've created/inserted the InlineShape you're having a problem with.
But you describe them as <Word.Picture.8> so presumably these InlineShapes have a valid
OLEFormat property? In other words you used something like this to determine the class
type:

Debug.Print ActiveDocument.InlineShapes(1).OLEFormat.ClassType

If this is the case I'm wondering whether there is no registered application for this
class type, or if the registrations screwed up. You might want to check out the OLEFormat
objects ActivateAs method.

HTH + Cheers - Peter


(e-mail address removed) (rob), said:
 
R

rob

Thanks for you reply.
the inline shape type that is giving me the problem
wdInlineShapePicture. most times you get nothing from
ActiveDocument.InlineShapes(1).OLEFormat implying that the oleformat
is not set hence we cannot use the activateAs command.
I have tried this morning to read the progid or classtype this morning
getting the nothing error (No valid oleformat property). how else can
we activate these inline pictures if we get nothing from oleformat,
because we need to process these pictures including any other object
that might be embedded in them like text boxes

thanks again for you help
Robert
 
C

Cindy M -WordMVP-

Hi Rob,
I am having trouble with inlineshape.item(i).activate command. this
command works fine with most inlineshapes, but we have some word
picture.8 that will not/cannot be activated on certain machines.
Exactly what do you expect should happen when such a picture is
"activated"?

What graphics file format would such a picture have been, originally?
the inline shape type that is giving me the problem
wdInlineShapePicture. most times you get nothing from
ActiveDocument.InlineShapes(1).OLEFormat implying that the oleformat
is not set hence we cannot use the activateAs command.
I have tried this morning to read the progid or classtype this morning
getting the nothing error (No valid oleformat property). how else can
we activate these inline pictures if we get nothing from oleformat,
because we need to process these pictures including any other object
that might be embedded in them like text boxes

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 
R

rob

thanks for replying
1. Well if the picture is successfully activated, word will display it
as a seperate document. The original picture cannot be accessed until
the new window with only the picture embedded is closed. This new
document , named by word as "picture ....", can be processed (i.e.
iterating through the documents contents e.g. text boxes, triangle and
probably any other embedded pictures.)


2. it could be any graphic file format that word supports. in truth it
could be any number of formats. especially the wdInlineShapePicture
inlineshape type.
it is not an ole object either.

if we cannot activate these pictures at all on any machine then
problem solved,
but we can actually execute that command (inlineshape.activate )
successfully on certain destop machines with word xp 2002 sp2
installed. but this command fails everytime on server machines with
the same install of word. the only difference I can see is the word
install done for the server machine don't have outlook installed with
word.

also these picture are not ole objects so I cannot get at their prodID
or ClassType either to go the activeas route as peter suggested.
we have microsoft word 2002 (10.5815.4219)sp-2 installed on both
destop and server machines.

pardon the encrypted description , let me know if you need anymore
feedback.
i will append more once i discover anymore.

thanks again
for your help.
 
C

Cindy M -WordMVP-

Hi Rob,

OK, I think I follow. What you're trying to do is force the graphics to
open in Word's Picture Editor, from the sound of it. The picture editor
can only "activate" for certain types of graphic formats - mostly just
*.wmf (Word's "native" graphics file format). All Drawing Object fall
into this category. And, once one is in the Picture Editor, other
graphics, as well as text, can be inserted and made part of the
"picture".

While I know that much :), I don't know what would make the Picture
Editor available on one machine, and not on another. But you might try a
couple of things in the UI, to see if it's a problem with the VBA
interface, or a configuration problem on the machine:

1. From Tools/Customize/Commands, category: Drawing. Pull the "Word
Picture" entry onto a toolbar (I usually put it in the Drawing toolbar).

2. Click on it, and the picture editor should open. If this doesn't
work, then you know where to start investigating.

3. If that works, click "Close picture", delete the empty picture that
was generated.

4. Draw a shape (any Drawing object). Make sure it's selected, then
click the "Word picture" button. (This should be the stage you're at
when the macro code executes) Then right-click and choose "Open". you
should land in the Picture editor?

(Note: I'm doing this in Word 2003, but I think 2002 and 2003 are the
same, in this respect. Earlier versions differ somewhat, as I recall.)

5. Recording the "Open picture" step gives me this code:

Selection.InlineShapes(1).OLEFormat.DoVerb VerbIndex:=1

Further, I see:

Selection.InlineShapes(1).OLEFormat.ClassType =
and
Selection.InlineShapes(1).OLEFormat.ProgID =
Word.Picture.8

1. Well if the picture is successfully activated, word will display it
as a seperate document. The original picture cannot be accessed until
the new window with only the picture embedded is closed. This new
document , named by word as "picture ....", can be processed (i.e.
iterating through the documents contents e.g. text boxes, triangle and
probably any other embedded pictures.)


2. it could be any graphic file format that word supports. in truth it
could be any number of formats. especially the wdInlineShapePicture
inlineshape type.
it is not an ole object either.

if we cannot activate these pictures at all on any machine then
problem solved,
but we can actually execute that command (inlineshape.activate )
successfully on certain destop machines with word xp 2002 sp2
installed. but this command fails everytime on server machines with
the same install of word. the only difference I can see is the word
install done for the server machine don't have outlook installed with
word.

also these picture are not ole objects so I cannot get at their prodID
or ClassType either to go the activeas route as peter suggested.
we have microsoft word 2002 (10.5815.4219)sp-2 installed on both
destop and server machines.

pardon the encrypted description , let me know if you need anymore
feedback.
i will append more once i discover anymore.

Cindy Meister
INTER-Solutions, Switzerland
http://homepage.swissonline.ch/cindymeister (last update Sep 30 2003)
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 :)
 
R

rob

Hello Cindy,
Thank again for your reply , very helpful. We have not got to the root
of the problem, but we resorted to reinstalling word 2002 xp on the
affected servers and wala word can now activate those word.picture.8
inline shapes. Before the reinstall we could not read the progID or
ClassType for the affected pictures.

We still have a couple of machines that have not been reinstalled,
hopefully we can get some answer about what went wrong with the
previous installs.
just giving you (and others ) some update on the problem.

Also I tried your suggestion to activate the affected pictures via the
tools-options-customize. if you selected all commands and add activate
shape to the tool bar. if you highlight any picture the activate shape
menu ,you just added to the toolbar, will be enabled if word can
activate the picture and not enabled if it cannot activate the
picture. This is a quick test to determine if word can activate the
picture or not (before going in code ).

thanks
 

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