update embedded shape (OLE)

V

Veronika Zenz

hi,

I've got two questions concerning embedded shapes and automation:

* is it possible to programmatically update an embedded ole shape in a
visio drawing?
* how can I get the filename of the target of an embedded shape?

manually these tasks can be done using the edit->links dialog, but I
don't want to call the dialog (viscmdeditlinks) but automatically
perform the action (e.g. update).

any help appreciated,
veronika
 
J

JuneTheSecond

If it is Excel, there is a\someone posted a good example like,
Sub test()
On Error GoTo ERRMSG
Dim xlSheet As Excel.Worksheet
Set xlSheet = Nothing
Set xlSheet = ActivePage.Shapes(1).Object.Worksheets(1)
xlSheet.Range("A2").Copy
xlSheet.Paste xlSheet.Range("B2")
Set xlSheet = Nothing
Exit Sub
ERRMSG:
Set xlSheet = Nothing
MsgBox Err.Description
End Sub
 
V

Veronika Zenz

Thanks for your answer!

When I try to access the Shapes Object Property I get an Exception
"Ausnahme aufgetreten" - "Exception occured"
Error Number: -2032465768

I created a minimal example

Sub ole()
On Error GoTo ERRMSG
Dim obj As Object
Set obj = Nothing
MsgBox ActivePage.Shapes(1).ForeignType ' prints -32512 ->
OLE ok
Set obj = ActivePage.Shapes(1).Object ' throws an
Error
Set obj = Nothing
Exit Sub
ERRMSG:
Set obj = Nothing
MsgBox Err.Description
MsgBox Err.Number
End Sub


A similar error has been reported in
http://groups.google.at/group/microsoft.public.visio.developer.vba/msg/fb3ae74b94daf53b

do you have any ideas whats wrong?
 
N

Nikolay Belyh

Not sure what are you doing (you'd better describe the initial problem
in a human languate, "embedded ole shape" sounds a bit scary..), but I
can propose some generic solution for the situation when you can do
something manually but fail to do the same thing using automation.
Maybe this will be helpful.

Visio has a nice feature - the macro recorder. You just start
recording, "do the thing" manually, and stop recording when you are
done. Now you can open VBA window, and examine at the VBA code Visio
has generated while recording your actions.

Kind regards, Nikolay.
 
V

Veronika Zenz

Hi Nikolay,
Not sure what are you doing (you'd better describe the initial problem
in a human languate, "embedded ole shape" sounds a bit scary..), but I

You're right, not a very lucky term, and incorrect too, cause what I
really mean are linked objects, not embedded ones.

Visio has a nice feature - the macro recorder.

The macro recorder is a really handy tool, but for the edit->links
dialog it does not generate any sourcecode. alas!

best regards, Veronika
 
V

Veronika Zenz

ActivePage.OLEObjects(1).Object
throws the same error (Exception Occured).

All other Properties like ObjectType and ProgID can be accessed
without error.

Another thing that seems strange: when I insert a visio file as a
link, its ProgID is Visio.Drawing.11 although I'm using Visio 2007 and
also created the Drawing using Visio 2007. Shouldn't the ProgID then
be Visio.Drawing.12?

Thanks in advance, Veronika
 
N

Nikolay Belyh

Sorry, can't help here.
When you call "Object" property of OLEObject an external program this
object belongs to is launched.
For all other properties of OLEObject it is not (Visio handles them).

BTW, it seems that you are just inserting a reference to Visio drawing
in another Visio drawing?
In this case you can consider using "Hyperlinks" for this perpose.
They are much more natural for referig other drawings,
you can manipulate them programmatically without any problems.
 

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