Dynamics AX Knowledge

  博客园  :: 首页  :: 新随笔  :: 联系 :: 订阅 订阅  :: 管理
    In Axapta, How to write data to Word? The below could implement  the simple function for writing data to Word.

    //define COM interface
    COM         wordApplication ;
    COM         wordDocuments ;
    COM         wordDocument ;
    COM         wordRange ;
    ;

    //instantiation
    wordApplication     = new COM("word.application");
    wordApplication.visible(true);

    wordDocuments       = wordApplication.Documents();

    wordDocument        = wordDocuments.add();

    //Get a word document
    wordDocument.saveas("C:\Axapta.doc");

    //Write the data to word
    wordDocument.activate();

    wordRange           = wordDocument.range(0,0);
    wordRange.insertafter("Hello Axapta Word");

    //Save and close document
    wordDocument.save();
    wordDocument.close();
    wordApplication.quit();

posted on 2007-11-29 16:07  Jacky Xu  阅读(255)  评论(0编辑  收藏  举报