Discussion:
opening a word document from a visio macro
(too old to reply)
Mike Movchan
2006-02-16 06:48:03 UTC
Permalink
Ok, I am very new at this... this is what I am trying to do: I am using the
DblClickEvent [=RUNADDON("A")] to launch a macro that will open a specific
word document for the shape clicked. The first part is working however I am
having prolems getting visio to open a word doc... below is the code

Sub A()
Dim WrdDoc As Word.Document
Set WrdDoc = Documents.Open("C:\test\MyDoc.doc")
End Sub

and I get a runtime error:
Run-time error '-2032466868(86db044c)':
Visio cannot open the file because it's not a Visio file or it has become
corrupted.

Any suggestions?
Chris [Visio MVP]
2006-02-16 08:54:21 UTC
Permalink
Visio thinks you're making a call to Visio with your Documents.Open call.

You need something more like this:

dim wApp as Word.Application
set wApp = CreateObject("Word.Application") '... not sure if that's the
correct string...
set wDoc = wApp.Documents.Open(...)


When you Dim your variables, prefix them all with Visio.___ and Word.___ to
avoid confusion. Both apps have Document, Application, and probably some
other like-named objects. The prefixing makes things clearer to VBA.
--
Hope this helps,

Chris Roth
Visio MVP
Post by Mike Movchan
Ok, I am very new at this... this is what I am trying to do: I am using the
DblClickEvent [=RUNADDON("A")] to launch a macro that will open a specific
word document for the shape clicked. The first part is working however I am
having prolems getting visio to open a word doc... below is the code
Sub A()
Dim WrdDoc As Word.Document
Set WrdDoc = Documents.Open("C:\test\MyDoc.doc")
End Sub
Visio cannot open the file because it's not a Visio file or it has become
corrupted.
Any suggestions?
Al Edlund
2006-02-16 10:50:53 UTC
Permalink
you could also do it with a hyperlink (has the added advantage that if you
have bookmarks in your word doc it can go to the bookmark)
al
Post by Mike Movchan
Ok, I am very new at this... this is what I am trying to do: I am using the
DblClickEvent [=RUNADDON("A")] to launch a macro that will open a specific
word document for the shape clicked. The first part is working however I am
having prolems getting visio to open a word doc... below is the code
Sub A()
Dim WrdDoc As Word.Document
Set WrdDoc = Documents.Open("C:\test\MyDoc.doc")
End Sub
Visio cannot open the file because it's not a Visio file or it has become
corrupted.
Any suggestions?
Continue reading on narkive:
Loading...