Hi, can anyone help me. I've trying to display existing word document in vb.net but i keep getting this error:

D:\System-new\DLIMS\PSM2\FormUserGuideWord.vb(58): Type 'COMExceptionMessageBox.Show' is not defined.

I have add reference (Microsoft word 11.0 because im using ms word 2003) to my project but i still cannot display the word document.
Below is the code that i write to open word document in vb.net 2003:

Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Word

Public Class FormUserGuideWord
Inherits System.Windows.Forms.Form

Private Sub FormUserGuideWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strFileName As String
Dim word As New Microsoft.Office.Interop.Word.Application
Dim doc As Microsoft.Office.Interop.Word.Document
Try
doc = Word.Documents.Open("D:\System\DLIMS\UserGuide.doc")doc.Activate()
Catch ex As COMExceptionMessageBox.Show("Error accessing Word document.")
End Try

End Sub
End Class

Hopefully someone can help me to solve my problem. TQ.

Hi PJA.

Bear with me as this is my first post on daniweb :)

Replace your code with the following and your problem should be solved.

Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop.Word

Public Class FormUserGuideWord
Inherits System.Windows.Forms.Form

Private Sub FormUserGuideWord_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load
Dim strFileName As String
Dim word As New Microsoft.Office.Interop.Word.Application
Dim doc As Microsoft.Office.Interop.Word.Document
Try
doc = Word.Documents.Open("D:\System\DLIMS\UserGuide.doc")doc.Activate()
Catch ex As COMExceptionMessageBox.Show("Error accessing Word document.")
End Try

End Sub
End Class

When you attempt to Catch the COM exception you then need to show a messagebox.

Hope this was helpful

Regards
Leigh

HELLO SIR THANK YOU FOR THE CODE BUT I ALSO WANT THE DESING
FOR SEE WHICH COMPONET U CAN USE

What is DESING?

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.