469,657 Members | 1,819 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,657 developers. It's quick & easy.

Interop Word & VB problem

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
2 8010
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
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.

Similar topics

3 posts views Thread by Dustin van de Sande | last post: by
7 posts views Thread by R Reyes | last post: by
3 posts views Thread by Hospital S.Sebastiao | last post: by
1 post views Thread by =?ISO-8859-1?Q?S=F8ren?= | last post: by
reply views Thread by gheharukoh7 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.