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 AX (Archived)

Where can I get COM objects for MS Office for programming

(0) ShareShare
ReportReport
Posted on by

Hello I want to write to word document from X++. Where can I get the COM components related to word document so that I can understand and programs accordingly. Please send me the links.

*This post is locked for comments

I have the same question (0)
  • Suggested answer
    Martin Dráb Profile Picture
    237,996 Most Valuable Professional on at

    Install it together with Microsoft Office. I think there is an option in the installer about Interop, therefore ensure yourself that it's ticked.

  • Community Member Profile Picture
    on at

    Martin I am talking about create a word document from X++ code. Like the below one:

    static void CreateWordDocument1(Args _args)

    {

    Filename template;

    CustTable custTable;

    COM word;

    COM documents;

    COM document;

    COM bookmarks;

    COM bookmark;

    COM range;

    void processBookmark(str _name, str _value)

    {

    if (!bookmarks.exists(_name))

    {

    return;

    }

    bookmark = bookmarks.item(_name);

    range = bookmark.range();

    range.insertAfter(_value);

    }

    #define.Word('Word.Application')

    #define.template(@'C:\temp\letter.dotx');

    custTable = CustTable::find('1101');

    try

    {

    word = new COM(#Word);

    }

    catch (Exception::Internal)

    {

    if (word == null)

    {

    throw error("Microsoft Word is not installed");

    }

    }

    documents = word.documents();

    document = documents.add(#template);

    bookmarks = document.bookmarks();

    processBookmark('Customer',

    custTable.name());

    processBookmark(

    'User',

    HcmWorker::find(

    DirPersonUser::current().worker()).name());

    processBookmark(

    'Company',

    CompanyInfo::find().Name);

    processBookmark(

    'Phone',

    CompanyInfo::find().phone());

    word.visible(true);

    }

    Now where can I get the description of individual functions used in the above code related to COM like

    COM word;

    COM documents;

    and other things

  • Community Member Profile Picture
    on at

    I want to use the X++ code to write to a word template like salary template in which i want to write the data. I want the description of these COM related codes for creating word document creation. office ads-in is an option but my manager want me to do it from X++.

  • Suggested answer
    Martin Dráb Profile Picture
    237,996 Most Valuable Professional on at

    I answered your question "Where can I get the COM components related to word document?".

    If you want to understand how to use these COM objects, I recommend the documentation for Primary Interop Assemblies. It's not exactly the same, but close. Your favorite search engine will help you when looking for something specific.

  • Community Member Profile Picture
    on at

    Okay Thanks I will search it.

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 AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#1
Martin Dráb Profile Picture

Martin Dráb 4 Most Valuable Professional

#3
MyDynamicsNAV Profile Picture

MyDynamicsNAV 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans