How to Add Visio Drawing with AddOLEObject

D

Dr3Bob

FileName:="C:\Book1.xls!Sheet1!R1C1:R6C3", I am using AddOLEObject to insert
a Visio drawing into a word document using VBA. I am using the
Shapes.AddOLEObject. I know that for an Excel object you can specify a range
(e.g. FileName:="C:\Book1.xls!Sheet1!R1C1:R6C3") in the file name.

What is the syntax for referencing a page within the Visio file?
In Word 2003 it was something like FileName:="C:\MyFile.vsd#MyPage". This
does not appear to work in Word 2007.
 
P

Peter Jamieson

AFAICS you can use a single backslash, e.g.

Selection.InlineShapes.AddOLEObject _
FileName:="C:\mydrawings\Drawing1.vsd\Drawing\~Page-2", _
LinkToFile:=True, _
DisplayAsIcon:=False

This inserts a suitable LINK field with the file name as
"C:\mydrawings\Drawing1.vsd" and the subset/item name as "Drawing\~Page-2"

(If you Edit->Copy a page from one of your diagrams and Edit->Paste Link
into a new Visio 2007 diagram , then go to Edit->Links you should see an
example of the item names that Visio is expecting to use, just in case
they are different from previous versions.


Peter Jamieson

http://tips.pjmsn.me.uk
 
D

Dr3Bob

Thanks for your help, Peter.

This does appear to work. When I first tried it, it did not seem to work,
but with your reinforcement I tried it again.

I really wish Microsoft would document these things more thouroughly.

Regards,
Bob H.
 
P

Peter Jamieson

That's interesting, because I also had trouble first time around. In the
end I decided it was because I had included the Classname parameter as
well, but perhaps that was only part of the problem.
I really wish Microsoft would document these things more thouroughly.

Me too.

Peter Jamieson

http://tips.pjmsn.me.uk
 
D

Dr3Bob

That may have been my problem also, because included the Classname parameter
too. Mainly because the macro generated it that way.

Oh well.
Bob H.
 

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