473,395 Members | 1,791 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,395 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 8179
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:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
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...

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.