How to Creat an Word Document with a Report ?

BT_MarcBT_Marc Member Posts: 30
Hello,

First of all I have to say that I'm a beginner in programming.

I want to create a Word Document directly out of a Navision Report. Unfortunately I don't know the C/AL Code that will create a New Word document. First of all I have to create a new document with some text in it. Can some body tell my how I make it in Navision 3.70.0.14988 ?

Thanks for yor Help

Marc

Comments

  • SavatageSavatage Member Posts: 7,142
    You can save the report as HTML & open it in word.

    Also in the Application Designers Guide (on Product CD) in "Extending C/al" Chapter there is a step by step example of how to write a letter in MS Word.
  • diptish.naskardiptish.naskar Member Posts: 360
    I tried to save a report which had certain picture contols and some shape controls in html format and then opened the same in the word document but the formatting of the same had actually gone for a toss and in no way it was nice to see a word document as it should have looked.
    Diptish Naskar
    For any queries you can also visit my blog site: http://msnavarena.blogspot.com/
  • SavatageSavatage Member Posts: 7,142
    Yes it's not always pretty - that's why I prefer printing to PDF myself.

    But if editing is involved then I use Crystal Reports which exports a report perfectly to word.

    there are many ways to do this i guess. You could create the doc in word and use c/odbc or odbc to bring the data TO word instead of the other way around.
  • BT_MarcBT_Marc Member Posts: 30
    TemplateName := 'Dokument.dot';
    
    IF ISCLEAR(WordApp) THEN
    IF NOT CREATE(WordApp, FALSE) THEN
       ERROR('Konnte keine Word-Instanz erstellen!');
    
    IF NOT EXISTS(TemplateName) THEN
      ERROR('Wordvorlage %1 existiert nicht!', TemplateName);
    
    WordDoc := WordApp.Documents.Add(TemplateName);
    
    WordRange := WordApp.ActiveDocument.Fields.Item(1).Result;
    WordRange.Text := '1. Textfeld im Dokument füllen';
    
    WordRange := WordApp.ActiveDocument.Fields.Item(2).Result;
    WordRange.Text := '2. Textfeld im Dokument füllen';
    
    WordApp.ScreenUpdating(TRUE);
    WordApp.Visible := TRUE;
    WordApp.Activate;
    

    I found this Code

    It needs some Globals:

    Name DataType Subtype Length
    TemplateName Text 255

    WordApp Automation 'Microsoft Word 11.0 Object Library'.Application

    WordDoc Automation 'Microsoft Word 11.0 Object Library'.Document

    WordRange Automation 'Microsoft Word 11.0 Object Library'.Range

    It locks like this is the right funktion but there is a bug an i don't finde it. can some body help me ?
Sign In or Register to comment.