Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics NAV (Archived)

MS Word Automation Numered List

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

  • Neville Foyn Profile Picture
    Neville Foyn 4,320 on at
    RE: MS Word Automation Numered List

    Happy to help :)

  • Fausto Serrata Profile Picture
    Fausto Serrata 75 on at
    RE: MS Word Automation Numered List

    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');

  • Verified answer
    Neville Foyn Profile Picture
    Neville Foyn 4,320 on at
    RE: MS Word Automation Numered List

    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

  • Community Member Profile Picture
    Community Member Microsoft Employee on at
    RE: MS Word Automation Numered List

    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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Suggested Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,269 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,198 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans