473,326 Members | 2,114 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,326 software developers and data experts.

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 8174
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

1
by: Bob N5 | last post by:
I am working on an application that uses interop to do some simple operations with both Excel and Word. I have most of functionality working, but ran into issues on making things work with both...
2
by: William LaMartin | last post by:
I have created a program that allows for the automation of things in Word documents, like changing the values of DocVariables and the links to Excel Sheets. I did it using interoperoperatability,...
3
by: Dustin van de Sande | last post by:
I'm developing a ASP.NET 2.0 web application which exports and imports Word documents. The functionality is implemented in a DLL project which is referenced by the web application. In the DLL...
7
by: R Reyes | last post by:
Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? I'm trying to manipulate MS Word from my Web Form application and I can't get passed...
1
by: R Reyes | last post by:
ISSUE (reposted) =========================== Can someone please explain to me why I can't get the MS Word Interop assembly to work in my VS2005 project? For many people, they say they add the...
3
by: Hospital S.Sebastiao | last post by:
Hi, i'm in desperate need of help to fix a problem that i have, the problem is the following: I have an ASP.NET aplication that to open an word template document, this aplication is in C#(using...
9
by: sajithkahawatta | last post by:
my web page C#.net is work properly in my iis .but when i publish in another server it give errers.i used vs2005 and ms word 2003. but in the server there is no vs2005 or word installed. it has only...
1
by: =?ISO-8859-1?Q?S=F8ren?= | last post by:
Hi guys I got the following code: ------------------------------------------------------- Dim Word As New Microsoft.Office.Interop.Word.Application Dim Document As...
0
by: Luft | last post by:
I'm just starting to work with VSTO and Word 2007 but I've run into a problem when trying to create an add-in. I get the warning: This project references the primary interop assembly for Microsoft...
0
by: ryjfgjl | last post by:
ExcelToDatabase: batch import excel into database automatically...
0
by: Vimpel783 | last post by:
Hello! Guys, I found this code on the Internet, but I need to modify it a little. It works well, the problem is this: Data is sent from only one cell, in this case B5, but it is necessary that data...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
1
by: PapaRatzi | last post by:
Hello, I am teaching myself MS Access forms design and Visual Basic. I've created a table to capture a list of Top 30 singles and forms to capture new entries. The final step is a form (unbound)...
1
by: CloudSolutions | last post by:
Introduction: For many beginners and individual users, requiring a credit card and email registration may pose a barrier when starting to use cloud servers. However, some cloud server providers now...
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.