Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Error when loading Word Object with Win2k

Status
Not open for further replies.

SLamb88

Programmer
Apr 4, 2002
9
US
I have a program coded in VB 6.0, and when the user clicks on a button, it opens up a document in word, the code in the click event looks like this:

Dim objWord As Word.Application
Dim strMessage As String
Dim intResult As Integer

If bFileExists(gStrText) Then
Set objWord = New Word.Application
objWord.Visible = True
objWord.Documents.Open gStrText
End If

Pretty straightforward. The problem is that it works like a charm with machines loaded with Windows NT 4.0, but when we run it on Windows 2000 machines, we get an error that says:
Run-time Error -2147024894(80070002)
Automation Error
The System Cannot find the file specified.

It's a VBOK messagebox, and clicking on OK kills the entire application. Has anyone seen anything like this before? BTW: The same app can call Excel without any problems. In both cases, Word and Excel are version '97. I have verified that the Microsoft Word 8.0 Component Library (MSWORD8.OLB) is an included component. When I step through the project, it appears that the variable objWord never gets set. VB always reports it's value as "nothing", even after the "set" statement.
 
Are there any replies to this thread? I am having the exact same problem.

Thanks
 
Maybe not of much help but the following works fine with Word 2003.

Code:
Private Sub Form_Load()
Dim objWord As Word.Application
  Dim strMessage As String
  Dim intResult As Integer
  Dim gStrText As String

  CommonDialog1.ShowOpen
  gStrText = CommonDialog1.FileName
  
    
  If gStrText <> "" Then
    Set objWord = New Word.Application
    objWord.Visible = True
    objWord.Documents.Open gStrText
  End If
End Sub

Regards

Frederico Fonseca
SysSoft Integrated Ltd
 
Check your project references to see that they reference the version of Word on the machine you're running the program on.

If you have different versions of Word installed, then you may need to look up 'Late Binding'

________________________________________________________________
If you want to get the best response to a question, please check out FAQ222-2244 first

'If we're supposed to work in Hex, why have we only got A fingers?'
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top