Try Microsoft Edge
A fast and secure browser that's designed for Windows 10
We are trying to create an outlook appointment from a NAV Contact card with a hyperlink in the appointment body, back to the Contact card. Everything is working except for the hyperlink. When we try to set the Selection from Word.window.selection, we get this error: A call to Microsoft.Office.Interop.Word.Window.Selection failed with this message: Object does not match target type. We are using WordSelection dotnet variable set to Word.Selection object. We have this working in Visual Studio 2017, but cannot get past this error in NAV 2015. We are using Word to add the hyperlink to outlook appointment.
It seems a cast error. Are you sure that the selected element is exactly what you want? Is Word.selection the correct object you're casting?
I am as sure as I can be. I set the same variables in VB 2017 and it worked.
This is the line throwing the error:
WordSelection := WordWindow.Selection();
WordSelection defined as Interop.Word.Selection
WordWindow defined as Interop.Word.Window
Strange... this seems a cast error or an object non initialized error.
In Standard NAV check the codeunit 5054 and see if there is anything helpful to achieve it.
The variables used for .net work in VB, but not in NAV. Used another variable in place of .Selection and the function is now working.
Business Applications communities