Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / December 2006

Tip: Looking for answers? Try searching our database.

Saving embedded Visio objects as Visio files

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Chris - 06 Dec 2006 18:16 GMT
Our Word documents include Visio objects whose original files are now
scattered. I need VBA to do the equivalent of double-clicking to open
the object in Visio, saving as a file, and then returning to Word to
find the next Visio object. I've been looking at examples of calling
other apps, but I don't understand how to move between Word and Visio
as I described. Any example code would be a big help.
Cindy M. - 08 Dec 2006 17:38 GMT
Hi Chris,

> Our Word documents include Visio objects whose original files are now
> scattered. I need VBA to do the equivalent of double-clicking to open
> the object in Visio, saving as a file, and then returning to Word to
> find the next Visio object. I've been looking at examples of calling
> other apps, but I don't understand how to move between Word and Visio
> as I described.

Well, I can only give you the Word side of things. You'll need to ask
in a Visio group to get help with automating Visio.

Any OLE object embedded in a Word document is - as far as Word is
concerned - a graphic. It's either an InlineShape (Word treats it like
a text character) or a Shape (text wrap formatting is applied).

Both InlineShapes and Shapes have an OLEFormat.Object property that
lets you activate and access the automation interface of an OLE object.
Mainly, I do this with Excel, so here's an example for that you can use
as a basis:

Sub ExcelObject()
   Dim of As Word.OLEFormat
   Dim oXL As Excel.Workbook
   
   Set of = ActiveDocument.InlineShapes(1).OLEFormat
   of.Activate
   Set oXL = of.Object
   Debug.Print oXL.Name
End Sub

Note that you have to set a reference to the object library of what you
want to manipulate if you want to use intellisense. Otherwise, you have
to Dim oXL As Object (late-binding). I recommend you at least start
with a reference and Intellisense if you don't know Visio's object
model at all. At a later point you can remove it and change any
declarations to use the Object type.

Now you have to work with the Visio folks to find out

1. What type of object is stored in a Word document
2. How to declare and refer to that in your code
3. The syntax to save it to a separate file.

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 :-)
Chris - 08 Dec 2006 21:22 GMT
Thanks for your helpful response. You've pointed me to some other
useful information. But the examples from you and other sources stop on
statements such as

     Dim oXL As Excel.Workbook

with the message:

    "User-defined type not defined"

Thanks for any advice for remedying this.

> Hi Chris,
>
[quoted text clipped - 47 lines]
> This reply is posted in the Newsgroup; please post any follow question
> or reply in the newsgroup and not by e-mail :-)
Cindy M. - 24 Dec 2006 15:50 GMT
Hi Chris,

You need to go to Tools/References and activate the checkbox next to the
object library for the type of thing you're "talking to". For example,
the Microsoft Excel 11.0 object library.

> Thanks for your helpful response. You've pointed me to some other
> useful information. But the examples from you and other sources stop on
[quoted text clipped - 7 lines]
>  
> Thanks for any advice for remedying this.

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

Rate this thread:






 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.