Opening a Word document

T

Tim

I am trying to open a Word 97 document and I am getting
a "QueryInterface for interface Word._Application failed"
error message at the code line below. Any Suggestions? I
have installed office XP PIAs.

oDoc = oWord.Documents.Open("c:\filename.txt")

Tim

Additional code:

Imports Word = Microsoft.Office.Interop.Word

Dim oWord As Word.Application
Dim oDoc As Word.Document
Dim oRange As Word.Range
 
S

solex

Tim,

Here is some code that has worked for me. Insead of using the Imports
statement I set a reference to the Word Object Library (COM)

Good Luck,
Dan

Dim wrdApp As Word.Application
Dim wrdDoc As Word.Document
Dim wrdMailMerge As Word.MailMerge
Dim strDataFile As String
' Create an instance of Word and make it visible
wrdApp = CType(GetObject("", "Word.Application"), Word.Application)
wrdApp.Visible = True
wrdDoc = wrdApp.Documents.Open(TemplateName, False, True)
 
T

Tim

Thanks Dan, but now I am receiving a different error
message. "Specified cast is not valid"

Dim oWord As Word.Application
Dim oDoc As Word.Document

'error on this line
oWord = CType(GetObject("", "Word.Application"),
Word.Application)

Tim
 

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