Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / .NET Framework / Interop / January 2005

Tip: Looking for answers? Try searching our database.

Word Automation - RPC Error

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
J. Walker - 06 Jan 2005 03:08 GMT
I have a VB.Net app that creates a Word.Application and Word.Document
object. It loads a Word document. However, in my cleanup code when the user
closes the window, I call the Quit method the Word.Application object and
set the objects to nothign. This works fine except if the user closes Word
before closing the window. If the do this I get an "The RPC server is
unvailable" exception. Here's some sample code ...
Dim wa As Word.Application
Dim wd As Word.Document

Private Sub btnOpenDocument_Click(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles btnOpenDocument.Click
   wa = New Word.Application
   wd = wa.Documents.Open("C:\Temp\MyTestDocument.doc")

   wa.Visible = True
   wd.Activate()
End Sub

Private Sub Form3_Closing(ByVal sender As Object, ByVal e As
System.ComponentModel.CancelEventArgs) Handles MyBase.Closing
   wa.Quit()
   wd = Nothing
   wa = Nothing
End Sub

I thought I could check to see if WA Is Nothing, but that didn't work. Any
ideas on what I need to check to see if the user closed Word before the
Form3_Closing event fires? Thanks.

John
Fredrik Wahlgren - 06 Jan 2005 17:49 GMT
> I have a VB.Net app that creates a Word.Application and Word.Document
> object. It loads a Word document. However, in my cleanup code when the user
[quoted text clipped - 26 lines]
>
> John

Maybe you can catch the "user closes Word " event and set a property when
this happens.

/ Fredrik

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.