web
You’re offline. This is a read only version of the page.
close
Skip to main content

Notifications

Announcements

No record found.

Community site session details

Community site session details

Session Id :
Microsoft Dynamics NAV (Archived)

Outlook Interop

(0) ShareShare
ReportReport
Posted on by

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.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    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?

  • Community Member Profile Picture
    on at

    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

  • Suggested answer
    Stefano Demiliani Profile Picture
    37,166 Most Valuable Professional on at

    Strange... this seems a cast error or an object non initialized error.

  • Suggested answer
    Suresh Kulla Profile Picture
    50,243 Super User 2025 Season 2 on at

    In Standard NAV check the codeunit 5054 and see if there is anything helpful to achieve it.

  • Verified answer
    Community Member Profile Picture
    on at

    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.

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans