How to open an embedded Word doc using VBA?

J

JoAnn

I have an embedded Word document within an open Word document. I would like
to create a macro that opens the desired embedded Word document and goes to a
predefined bookmark within it.

Does anyone know how to do this programmatically? I'm using Word 2000 but
the doc will be used by Word 2000 & 2003 users.


Thanks for your help!
 
C

Chuck Henrich

The following code should get you started. It simply opens the first
InlineShape in the document and goes to the bookmark. It assumes your
embedded doc is inline, not floating - if it's floating then you need to use
Shapes instead of InlineShapes. This code is modified from code Cindy posted
in another thread
(http://www.microsoft.com/communitie...c111f2-4f15-46a9-8a50-097187515c9a&sloc=en-us)

Sub OpenEmbeddedDoc()
Dim shpInline As InlineShape
Dim docContainer As Document
Dim docEmbedded As Document
Dim olFormat As oleFormat

Set docContainer = ActiveDocument
Set olFormat = docContainer.Range.InlineShapes(1).oleFormat
olFormat.DoVerb wdOLEVerbPrimary
Set docEmbedded = olFormat.Object
docEmbedded.Bookmarks("hello").Range.Select
MsgBox "Is this your bookmark?"
Set docEmbedded = Nothing
End Sub

HTH
 

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