Wednesday, July 26, 2017

If you want to Open Word file through Job in Ax you can user COM variant and open word file through Job. Using COM variant or dialog Field, Word Documents through we can achieve this functionality in ax 2012.



Static void OpenWordTemplate()
{
    Dialog                       d;
    DialogField              dialogFilename;
    COM                         wordApp;
    COM                         wordDocuments;
    FileName                    fileName;
    wordApp = new COM("word.application");
    wordDocuments = wordApp.Documents();

    d = new Dialog();
    d.caption("select a file");
    dialogFilename = d.addField(extendedTypeStr(FilenameOpen),"File Name");//add a field where you select your file in a specific path
    d.run();//execute dialog
    if(d.closedOk())
    {
        filename = dialogFileName.value();//return path file value
    }
    try
    {
        wordDocuments.Open(fileName);
    }
    catch (Exception::Error)
    {
        throw error("File cannot be opened.");
    }
    wordApp.visible(true);
}
Happy DAX....

No comments:

Post a Comment

D365 Extensions: Extend the validateField Method on a Table

In this post I will going to show you, how to extend the validateField method on a table. As example I used the SalesLine, where I will ...