Chris
Fri Dec 08 15:22:54 CST 2006
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.
Cindy M. wrote:
> 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 :-)