Notifications
Announcements
No record found.
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
Install it together with Microsoft Office. I think there is an option in the installer about Interop, therefore ensure yourself that it's ticked.
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());
'Company',
CompanyInfo::find().Name);
'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
and other things
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++.
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.
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.
As AI tools become more common, we’re introducing a Responsible AI Use…
We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…
These are the community rock stars!
Stay up to date on forum activity by subscribing.
Priya_K 4
Martin Dráb 4 Most Valuable Professional
MyDynamicsNAV 2