VB.NET Visual Studio 2017-{0002095E-0000-0000-C000-000000000046}'- <Doesn't exist after upgrade to office 2016-

0

I am making a windows form in Visual Studio 2017 in VB.NET to simplify a reporting process. When I initially started making the form I was using office 2013 on a different laptop. I have since switched laptops and upgraded to office 2016. I checked regedit for the file and it doesn't exist. I'm stuck and don't know what to do. Any help would be much appreciated.

The error is being thrown at "rng = Oapp", and no the asterisk are not in my actual code just to clarify. Full error is below code.

Code:

 Private Sub ClientName_Click(sender As Object, e As EventArgs) Handles ClientName.Click
        Dim Oapp As Word.Application
        Oapp = CreateObject("Word.Application")
        Oapp.Documents.Open(FileName:=Environ("UserProfile") & "\Desktop\" & "UT Project-TEMPLATE\HEADER - CONTENT.docx")
        Dim FindText As String = "Client"
       Dim rng As Word.Range
        ***rng = Oapp***
        'Sections(1).Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage = 2).Range)
        'With rng
        '    .Find.Execute([FindText]:=("Client:"), [MatchCase]:=True, [Format]:=True, [ReplaceWith]:="Maratrhon Oil")
        'With Oapp.ActiveDocument.Sections(1).Footers(Word.WdHeaderFooterIndex.wdHeaderFooterFirstPage).Range
        '    .Find.Execute([FindText]:=("Client:"), [MatchCase]:=True, [Format]:=True, [ReplaceWith]:="bob")

        ' End With
    End Sub

Error shown:

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

vb.net
visual-studio
asked on Stack Overflow Jun 7, 2018 by Kevin Jurek • edited Jun 7, 2018 by Alex K.

0 Answers

Nobody has answered this question yet.


User contributions licensed under CC BY-SA 3.0