Tom's Guide | Tom's Hardware | Tom's Games
![]() |
![]() |
![]() |
I am trying to open a WORD document. Just one day ago it was working ok. Now i get the following:
QueryInterface for interface Word._Application failed.
at Word.ApplicationClass.set_Visible(Boolean prop)when i am trying to open a word document. I have a reference to Word 8.0, and when I tryed to change it to reference a Word 11.0 (Office 2003) after the debug it wasn't working. I even restored my backup file with the word 8 reference and again i get the same error. I deleted the whole directory that i had the program on and restored from back up and nothing. I tryed in a WIn98 machine with Office 2002 and worked OK. What the heck is going on? Any help please. I am attaching my set of commands.
/===============================================
Dim i As Integer
Dim oWord As Word.ApplicationClassoWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Open(Application.StartupPath & "\stecr1.doc")
//===========================================

Late-binding is the only way to work with multiple versions of Word... Therefore don't use a reference at design time, late-binding will grab the reference at run-time.
If you're wondering what I'm going on with about "Late-binding" then read-on!
You've bascially got the premise by using the createobject command. And an example follows:
TURN OFF OPTION STRICT
-----------------------
Dim i As IntegerDim oWord As OBJECT
oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Open(Application.StartupPath & "\stecr1.doc")------------------
The only difference is the "Dim oWord As OBJECT" bit... because we're just telling .Net that it's going to be a reference to something there, and then we define the reference by using the CreateObject command
http://www.appliedlanguage.com

Thank you Konichi. It worked. I just said dim oWord as Object and it worked like you said. Thank you again.

![]() |
batch file help
|
how to wipe out OS and st...
|

This post is quite old and has been locked from receiving new replies. Please create a new posting instead.
| Ads by Google |