Hello,
I am trying to find and replace tags on the word Document which loaded on windows form.to use the word.Range i declared
`Dim wd As Object = New Word.Document
Dim wa As Object = New Word.Application
wd = wordControl.ActiveDocument
wa = wd.Application
Dim HeaderFooter As Word.Range
Dim Header As Word.HeaderFooter
//Line1 and Line 2
HeaderFooter = wa.ActiveDocument.Range
For Each HeaderFooter In wa.ActiveDocument.StoryRanges
With HeaderFooter.Find
.Format = False
.Replacement.Highlight = 100
.Replacement.Font.Bold = True
.Text = "<<Client Name>>"
.Replacement.Text = "Mr. Client"
.Execute(Replace:=Word.WdReplace.wdReplaceAll, Forward:=True, Wrap:=Word.WdFindWrap.wdFindContinue)
End With`
Exception:
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: could not be found. (Exception from HRESULT: 0x80030002 (STG_E_FILENOTFOUND)).
for that I am Using
- Visual Studio 2005 professional edition
- MS Office 2003 professional edition
when I am trying to create a word or excel object the object shows all the properties as attached in the Image.but during the declaration it did not gave any exception:
I am using following dll and library as a reference:
- Interop.office.dll
- Interop.Excel.dll
- Interop.Word.dll
- Microsoft office 11.0 object Library
- Microsoft Excel 11.0 object Library
- Microsoft Word 11.0 object Library
This codes working fine in many combination of windows and MS Office.but give problem in some combination.
Regards,
Vaibhav