okie20
04-28-2004, 02:00 PM
I do not really understand this error:
'Quit' is ambiguous across the inherited interfaces 'Word._Application' and 'Word.ApplicationEvents2_Event'.
I am programming an Office type test program that will do an event for Word when button1 is clicked, Excel when button2 is clicked. When I use the same syntax for word and excel, I get the error above for Word (obviously). The excel sub I have works perfectly fine. My Word sub is this:
VB:
Imports Word
Public Sub wordevents()
Dim oWordApps As New Word.Application()
Dim oWordDoc As Word.Document = oWordApps.Documents.Add()
oWordDoc.Activate() 'Do I need this?
Dim oWDRan As Word.Range
oWordDoc.Range.Delete()
oWDRan = oWordDoc.Range(0, 0)
With oWDRan
.InsertBefore("This is just a test")
.Font.Name = "Verdana"
.Font.Size = 16
.InsertParagraphAfter()
.InsertParagraphAfter()
.InsertAfter("HEHEHEHE")
End With
oWordDoc.SaveAs("c:\vb\wordtest.doc")
oWordApps.Documents.Close()
oWordApps.Quit() ' THIS IS THE LINE THAT GIVES THE ERROR
oWDRan = Nothing
oWordApps = Nothing
oWordDoc = Nothing
GC.Collect()
End Sub
Any help would be appreciated
okie
'Quit' is ambiguous across the inherited interfaces 'Word._Application' and 'Word.ApplicationEvents2_Event'.
I am programming an Office type test program that will do an event for Word when button1 is clicked, Excel when button2 is clicked. When I use the same syntax for word and excel, I get the error above for Word (obviously). The excel sub I have works perfectly fine. My Word sub is this:
VB:
Imports Word
Public Sub wordevents()
Dim oWordApps As New Word.Application()
Dim oWordDoc As Word.Document = oWordApps.Documents.Add()
oWordDoc.Activate() 'Do I need this?
Dim oWDRan As Word.Range
oWordDoc.Range.Delete()
oWDRan = oWordDoc.Range(0, 0)
With oWDRan
.InsertBefore("This is just a test")
.Font.Name = "Verdana"
.Font.Size = 16
.InsertParagraphAfter()
.InsertParagraphAfter()
.InsertAfter("HEHEHEHE")
End With
oWordDoc.SaveAs("c:\vb\wordtest.doc")
oWordApps.Documents.Close()
oWordApps.Quit() ' THIS IS THE LINE THAT GIVES THE ERROR
oWDRan = Nothing
oWordApps = Nothing
oWordDoc = Nothing
GC.Collect()
End Sub
Any help would be appreciated
okie