By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
455,558 Members | 1,673 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 455,558 IT Pros & Developers. It's quick & easy.

Interop Word & VB problem

P: n/a
I'm using Visual Studio .NET (not 2003), and am
developing a class that works with Word theough the
Office PIAs (Interop). I can open word and do things
with it programatically, but I can't close it.
Specifically, when I try to call the Quit() method on the
application object, VB gives me the following error:

'Quit' is ambiguous across the inherited
interfaces 'Microsoft.Office.Interop.Word._Application'
and 'Microsoft.Office.Interop.Word.ApplicationEvents3_ Even
t'
Huh? Seems odd to me... All I'm doing is performing an
XSLTransform on some XML data, which changes it to HTML,
then opening the HTML in Word and saving it as a .doc
or .rtf file. It all works, including the file save, but
I can't call Quit() without getting the above error.
That leaves Word running in memory... Which is a very bad
thing.

I've included the source for the entire class for
reference. Help!

- Steve

------------ Begin Class code ---------------------
Imports System.IO
Imports System.Runtime.InteropServices
Imports Microsoft.Office.Interop
Imports System.Xml
Imports System.Xml.Xsl

Public Class clsWordGen

#Region " Globals "
Public sTempDir As String = "c:\temp\"
Public gTempFile As Guid
Public sFullTempPath As String
#End Region
Public Sub CreateWordDoc(ByVal sXMLFilePath As
String, ByVal sXSLFilePath As String, ByVal sOutFilePath
As String)
Dim myXslTransform As New XslTransform()
Try
myXslTransform.Load(sXSLFilePath)
gTempFile.NewGuid()
sFullTempPath = sTempDir & gTempFile.ToString
& ".html"
myXslTransform.Transform(sXMLFilePath,
sFullTempPath)

Dim WordApp As New Word.Application()
Dim objDoc As New Word.Document()

objDoc = WordApp.Documents.Open(sFullTempPath)
objDoc.SaveAs(sOutFilePath)

WordApp.Quit()

WordApp = Nothing

Marshal.ReleaseComObject(WordApp)
GC.Collect()
GC.WaitForPendingFinalizers()
Catch e As Exception
' pass exception up to caller
Throw e
End Try
End Sub

End Class
Nov 20 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Hello,

"Steve" <sb*******@imagingacceptance.com> schrieb:
I'm using Visual Studio .NET (not 2003), and am
developing a class that works with Word theough the
Office PIAs (Interop). I can open word and do things
with it programatically, but I can't close it.
Specifically, when I try to call the Quit() method on the
application object, VB gives me the following error:

'Quit' is ambiguous across the inherited
interfaces 'Microsoft.Office.Interop.Word._Application'
and 'Microsoft.Office.Interop.Word.ApplicationEvents3_ Even


BUG: Visual Basic .NET "'[Method]' is ambiguous across the inherited
interfaces" Error Message When Using Office Automation
http://support.microsoft.com/?kbid=315981

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
Nov 20 '05 #2

P: n/a
Thanks!!!
-----Original Message-----
Hello,

"Steve" <sb*******@imagingacceptance.com> schrieb:
I'm using Visual Studio .NET (not 2003), and am
developing a class that works with Word theough the
Office PIAs (Interop). I can open word and do things
with it programatically, but I can't close it.
Specifically, when I try to call the Quit() method on the application object, VB gives me the following error:

'Quit' is ambiguous across the inherited
interfaces 'Microsoft.Office.Interop.Word._Application'
and 'Microsoft.Office.Interop.Word.ApplicationEvents3_ Even
BUG: Visual Basic .NET "'[Method]' is ambiguous across the inheritedinterfaces" Error Message When Using Office Automation
http://support.microsoft.com/?kbid=315981

--
Herfried K. Wagner
MVP VB Classic, VB.NET
http://www.mvps.org/dotnet
.

Nov 20 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.