Unable to cast COM object error in SSIS

Tech Tip: Click here to run a free scan for Windows Errors and optimize PC performance



Hi.

From within SQL Server 2005 SSIS, I'm just trying to open a Word doc and
save it as .txt using a Script Task. I've added the
Microsoft.Office.Interop.Word assembly as per
http://msdn2.microsoft.com/en-us/library/ms136007.aspx and receive the
following error when I attempt to execute the Script Task containing the code
below. I've looked all over for a solution but to no avail. Please help! :)

Squidier


Unable to cast COM object of type
'Microsoft.Office.Interop.Word.ApplicationClass' to interface type
'Microsoft.Office.Interop.Word._Application'. This operation failed because
the QueryInterface call on the COM component for the interface with IID
'{00020970-0000-0000-C000-000000000046}' failed due to the following error:
No such interface supported (Exception from HRESULT: 0x80004002
(E_NOINTERFACE)).




Imports System
Imports System.Data
Imports System.Math
Imports Microsoft.Vsa
Imports Microsoft.SqlServer.Dts.Runtime
Imports Microsoft.Office.Interop.Word


Public Class ScriptMain

' The execution engine calls this method when the task executes.
' To access the object model, use the Dts object. Connections, variables,
events,
' and logging features are available as static members of the Dts class.
' Before returning from this method, set the value of Dts.TaskResult to
indicate success or failure.
'
' To open Code and Text Editor Help, press F1.
' To open Object Browser, press Ctrl+Alt+J.

Public Sub Main()

Dim wdApp As Microsoft.Office.Interop.Word.Application
Dim docNew As Microsoft.Office.Interop.Word.Document
Dim wrdConverter As Microsoft.Office.Interop.Word.FileConverter

'' Create new hidden instance of Word.
wdApp = New Microsoft.Office.Interop.Word.ApplicationClass()
'' Create a new document.
docNew =
wdApp.Documents.Open("H:\CSMOReporting\RemediationTracker\OfficeConverter\ADRAP Report - Baptist Healthcare.doc")


'docNew.SaveAs(FileName:="H:\CSMOReporting\RemediationTracker\OfficeConverter\ADRAP Report - Baptist Healthcare.txt", _
'
FileFormat:=Microsoft.Office.Interop.Word.WdSaveFormat.wdFormatText)

Dts.TaskResult = Dts.Results.Success
End Sub

End Class

.



Relevant Pages

  • Re: Module imports during object instantiation
    ... if verbose is True: ... you have because of the "execute code only once" behavior - if the ... This is what even my understanding is. ... Going with your point of try/except imports at the top level, ...
    (comp.lang.python)
  • Re: Executing UpdateGram with .NET Managed Class does nothing
    ... UpdateGrams return exception information in an XML response. ... the command using the ExecuteXmlReader method and reading the response, ... Imports System.IO ... When I execute an Updategram using the .NET Managed class nothing ...
    (microsoft.public.sqlserver.xml)
  • ActiveX for Transformation: only the first row is imported
    ... I have two connection objects, one transformation task (task1) that imports data from source to destination tables. ... And I have an ActiveX Script task. ...
    (microsoft.public.sqlserver.dts)
  • Re: Reading a in app.config
    ... question with what I did to get the code to execute but beings the code runs ... if others had a better method to reading a <SectionGroup> and found ... > name of the configuration file? ... >> Imports System.Configuration ...
    (microsoft.public.dotnet.framework)
  • Re: Coping with cyclic imports
    ... If you don't rely on imported things at top-level code (but only in ... Imports are pretty straightforward really. ... They execute ... module whether or not it has completed executing. ...
    (comp.lang.python)