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 :
Microsoft Dynamics NAV (Archived)

MS Word Automation Numered List

(0) ShareShare
ReportReport
Posted on by 75

Hi.

I want to program, from Dynamics Navision 2009 C/Side code, a function that generates in Word a numered list as show below.

  1. Textx
  2. Textx
  3. textxx
  4. text
  5. text

I know how to create, save and open the document. Also know how to insert text, tabs, and other things. But I could not manage to insert a numered list.

That's my problem. 

Any Idea.

*This post is locked for comments

I have the same question (0)
  • Community Member Profile Picture
    on at

    I haven't tried it but, how about opening a word doc (2010) goto Home-> turn on numbering, then select the numbering format you want.  Save it as a template.  Then use that template as the one you call from automation.

    Hopefully everything entered will get automatically numbered.

    Other Info:

    Walkthrough: Using Automation to Write a Letter in Microsoft Office Word

    msdn.microsoft.com/.../dd301252(v=nav.70).aspx

    How To Use Automation to Run a Word Macro with Arguments

    support.microsoft.com/.../183369

    How to create a bulleted or numbered list in Word

    support.microsoft.com/.../311877

  • Verified answer
    Neville Foyn Profile Picture
    4,320 on at

    Hi

    If you know a bit of VB you can also create a word doc, add a line of text, use the record macro functionality in word and set the line to bulleted, then stop and view the code of the macro, it takes a bit of trial and error but i managed to do some crazy stuff in excel using this method to figure out how the functions get called, then reproduce it in NAV

    Cheers

    Nev

  • Fausto Serrata Profile Picture
    75 on at

    Thanks for your suggestion Nev.

    Here I leave the code I used to solve my problem.

    Thank you again.

    CODE:

    NewLine := 13;

    Tab := 9;

    CLEAR(WordApp);

    IF ISCLEAR(WordApp) THEN

     CREATE(WordApp, TRUE, FALSE);

    WordDoc           := WordApp.Documents.Add;  //Add New Document

    WordAppSelection  := WordApp.Selection;

    WordApp.Run('Macro1'); //Activate the numered list

    WordAppSelection.TypeText('Text1');

    WordAppSelection.TypeText(FORMAT(NewLine));

    WordAppSelection.TypeText('Text2');

    WordAppSelection.TypeText(FORMAT(NewLine));

    WordAppSelection.TypeText('Text3');

    WordAppSelection.TypeText(FORMAT(NewLine));

    WordApp.Run('Macro2'); //Deactivate the numered list

    WordAppSelection.TypeText(FORMAT(NewLine));

    WordAppSelection.TypeText(FORMAT(NewLine));

    WordAppSelection.TypeText(FORMAT(TAB));

    WordAppSelection.TypeText('Texto3');

  • Neville Foyn Profile Picture
    4,320 on at

    Happy to help :)

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.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics NAV (Archived)

#1
HoangNam Profile Picture

HoangNam 7

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans