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 :

AX2012: Open Word Application through X++

Vishal Tiwari Profile Picture Vishal Tiwari 393
Just a small snippet to demonstrate, how we can open Microsoft word application through X++.

And this would be really significant when you want certain things to move from AX to Word for example print screen of AX forms to MS Word.

And here is the code:

Ex#1:
static void OpenWordTemplate()
{
  COM wordApp;
  COM wordDocuments;
  wordApp = new COM("word.application");
  wordDocuments = wordApp.Documents();

  wordDocuments.Open("c:\\CustomerDocument.docX");
  wordApp.visible(true);
}

Ex#2:
static void WordSaveAs()
{

  COM wordApp;
  COM wordDocuments;
  COM wordDocument;
  COM wordRng;

  wordApp = new COM("word.application");
  wordApp.visible(false);
  wordDocuments = wordApp.Documents();
  wordDocument = wordDocuments.add();
  wordRng = wordDocument.range(0,0);
  wordRng.insertafter("Customer account information");

  wordDocument.SaveAs("C:\\CustomerDocument.doc");

  wordApp.visible(true);
}


Happy Dax6ng J


This was originally posted here.

Comments

*This post is locked for comments