473,406 Members | 2,293 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Opening word document

Hi

I am using the code given at the end to open a word document from within
vb.net. It works fine the first time but the second time I get the error;

Unhandled Exception: System.Runtime.InteropServices.COMException
(0x800706BA): The RPC server is unavailable.
at Word.ApplicationClass.get_Documents()

The error occurs on the line WordDoc = WordApp.Documents.Add(<Template
name>)

Any idea what I am doing wrong? Surprisingly, if I open a backup copy of the
project (with the same code as far as I can see), it works! Does this mean
something has gone corrupt?

Thanks

Regards

= Code Follows ==================

Public Class clsOfficeWrapper

Private WithEvents WordApp As Word.Application
Private WithEvents WordDoc As Word.Document

Public Sub NewFax(ByVal Temp As String)

If WordApp Is Nothing Then
WordApp = New Word.Application
WordApp.Options.ShowControlCharacters = False
End If

WordDoc = WordApp.Documents.Add(Temp) '<== This lines gives error, the
second time round
With WordDoc
.ActiveWindow.Visible = True
End With

WordApp.Activate()
WordDoc = Nothing ' Kill the refernce only - not the document itself
End Sub

....

End Class
Nov 20 '05 #1
3 2402
The following article seems to suggest that I need to use wrdApp.Visible =
True immediately after creating word object. Anyone lese had this problem?>

Thanks

Regards

http://support.microsoft.com/default...&Product=wrd20
"John" <jo**@nospam.infovis.co.uk> wrote in message
news:%2******************@TK2MSFTNGP10.phx.gbl...
Hi

I am using the code given at the end to open a word document from within
vb.net. It works fine the first time but the second time I get the error;

Unhandled Exception: System.Runtime.InteropServices.COMException
(0x800706BA): The RPC server is unavailable.
at Word.ApplicationClass.get_Documents()

The error occurs on the line WordDoc = WordApp.Documents.Add(<Template
name>)

Any idea what I am doing wrong? Surprisingly, if I open a backup copy of the project (with the same code as far as I can see), it works! Does this mean
something has gone corrupt?

Thanks

Regards

= Code Follows ==================

Public Class clsOfficeWrapper

Private WithEvents WordApp As Word.Application
Private WithEvents WordDoc As Word.Document

Public Sub NewFax(ByVal Temp As String)

If WordApp Is Nothing Then
WordApp = New Word.Application
WordApp.Options.ShowControlCharacters = False
End If

WordDoc = WordApp.Documents.Add(Temp) '<== This lines gives error, the
second time round
With WordDoc
.ActiveWindow.Visible = True
End With

WordApp.Activate()
WordDoc = Nothing ' Kill the refernce only - not the document itself
End Sub

...

End Class

Nov 20 '05 #2
* "John" <jo**@nospam.infovis.co.uk> scripsit:
The following article seems to suggest that I need to use wrdApp.Visible =
True immediately after creating word object. Anyone lese had this
problem?>


Does the article solve your problem?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>
Nov 20 '05 #3
I think it has. I am still testing it though and I am using word 2000 not
word 97 which the article refers to.

Pretty weird, it worked all along and as the delivery date approaches it
starts to go all haywire.

Regards
"Herfried K. Wagner [MVP]" <hi***************@gmx.at> wrote in message
news:c0*************@ID-208219.news.uni-berlin.de...
* "John" <jo**@nospam.infovis.co.uk> scripsit:
The following article seems to suggest that I need to use wrdApp.Visible = True immediately after creating word object. Anyone lese had this
problem?>


Does the article solve your problem?

--
Herfried K. Wagner [MVP]
<http://www.mvps.org/dotnet>

Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Sivaraman.S | last post by:
Issue: When I am opening a word document or a template from an ASP.NET Web page (language used VB.NET Visual Studio Version 2003) using Word.ApplicationClass object (Reference Word 11.0 object...
3
by: Andy Davis | last post by:
I have set up a mail merge document in Word 2003 which gets its data from my Access 2000 database. I want to set up a button on a form that: 1. runs the query to provide the dat for the merge...
1
by: ourspt | last post by:
Hi, We are working on an ASP.NET (VB.NET) application and we have a problem opening a word document from our application. When we try to open the word document, we do not get any error...
2
by: Colin Halliday | last post by:
I have a Word 2003 mail merge main document (form letter) that is linked to another Word document data source for the mail merge. If I open this doc using the Word GUI, it first asks me to...
5
by: Cedric | last post by:
Hi Folks, I'm wondering if someone has already succeed to open a word2000 document located on server side with javascript code executed by a web browser on client side. In fact, i make it...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.