Create and Open Microsoft Word Document Programatically

zkyan

New member
Joined
Jun 6, 2007
Messages
3
Programming Experience
1-3
Hi All,

" The server threw an exception. (Exception from HRESULT: 0x80010105 (RPC_E_SERVERFAULT))"

I encountered the above message :( when i try to do the following:
(problem occur at the point where I open existing .doc file)
--------------------------------------------------------
Option Explicit On

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


Public Class frmTest

Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click

Dim word As New Application
Dim doc As New Document
Dim missing As Object = System.Reflection.Missing.Value
Dim rdonly As Object = False
Dim isVisible As Object = True
Dim fileName As Object = "C:\test.doc"


Try

doc = word.Documents.Open(fileName, missing, rdonly, missing, missing, missing, missing, missing, missing, missing, missing, isVisible)
doc.Activate()
'MORE FORMATTING ACTION TO BE DONE HERE

Catch ex As COMException
msgbox(ex.Message)
End Try


End Sub
End Class
-------------------------------------------------------------

Please let me know if you know how to resolve it. Thanks in advance and appreciate your great help.
 
Last edited:
:D HaHa.. Ask question and answer question by myself

Hurray!!! I found solution to it... Apparently the problem is caused by the bug in the COM object itself (not sure how true but if anyone can confirm please post reply here)..

Anw, the solution is... go to Microsoft Website to download the Office XP PIA (Primary Interop Assemblies) ....Office 2003 PIA is available as well...
After download extract it into your computer...

After extract it.. you should be able to see two file types in the folder. (Application Extension and Registration entries) Click on registration entries accordingly.

After that.. no more error message.. :D

Regards,
Kyan
 
Back
Top