Tuesday, 8 January 2013

Getting Bookmarks from Document Template using X++

Dear Friends,

Below is the code to get bookmarks from the specified document template using X++.

static void getBookMarks(Args _args)
{
    #define.Word('Word.Application')
    COM                 COMappl;
    COM                 coMdocuments, coMdocument, coMbookmarks, coMbookmark;
    Counter             cnt, i = 1;
    ;

    COMappl = COM::getObject(#Word);
    if (! COMappl)
        COMappl = new COM(#Word);

    coMdocuments    = COMappl.documents();

    coMdocument     = coMdocuments.add(@"D:\DocuTemplates\Request.dotx");
    coMbookmarks    = coMdocument.bookmarks();

    cnt             = coMbookmarks.count();

    while (i <= cnt)
    {
        coMbookmark = coMbookmarks.item(i);
        info(coMbookmark.Name());
        i++;
    }
}

No comments:

Post a Comment