Computing.Net > Forums > Programming > VB.NET and WORD

Computer Problems? Computing.Net has over 1,000,000 posts about all things technology related! Click here to start participating now! Also, check out the New User Guide.

VB.NET and WORD

Reply to Message Icon

Name: VASS
Date: November 17, 2004 at 18:12:10 Pacific
OS: win xp sp2
CPU/Ram: 512
Comment:

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.ApplicationClass

oWord = CreateObject("Word.Application")
oWord.Visible = True
oWord.Documents.Open(Application.StartupPath & "\stecr1.doc")
//===========================================



Sponsored Link
Ads by Google

Response Number 1
Name: konichi
Date: November 28, 2004 at 16:09:52 Pacific
Reply:

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 Integer

Dim 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


0

Response Number 2
Name: VASS
Date: November 29, 2004 at 20:09:28 Pacific
Reply:

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


0

Sponsored Link
Ads by Google
Reply to Message Icon

Related Posts

See More


batch file help how to wipe out OS and st...



Post Locked

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


Go to Programming Forum Home


Sponsored links

Ads by Google


Results for: VB.NET and WORD

Question Regarding VB.net and C# www.computing.net/answers/programming/question-regarding-vbnet-and-c/3580.html

VB.NET and C DLL's www.computing.net/answers/programming/vbnet-and-c-dlls/9509.html

vb.net and db www.computing.net/answers/programming/vbnet-and-db/14385.html