Opening a word doc from a visio macro

M

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

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?
 
J

JuneTheSecond

If you would like to start Word application and to open the document in the
Word,
you would write as,
Dim appWord As Word.Application
Dim WrdDoc As Word.Document
Dim Fname As String
Fname = "C:\test\MyDoc.doc"
Set appWord = New Word.Application
Set WrdDoc = appWord.Documents.Open(Fname)
And you might need to make reference to the Microsoft Word Object Library.
 

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