Export report using/merging 2+ word documents

monteiromonteiro Member Posts: 26
Hi,

I'm using Automation to generate a sales quote in Word from a pre-formated file. That's ok. Navision open this file, format the fields and show it. But I also need insert another file in this document.

Using record macro in Word, the command is "Selection.Inserfile". But doesn't exist in Navision (I hope this...).

In automation, I found a "SubDocument" class, but I don't know how to use the commands, inicialization, etc... :oops:

Someone have an idea or solved same situation? ](*,)

Thanks in advance,

Monteiro
Monteiro, Rodrigo
www.draeger-medical.com

Answers

  • monteiromonteiro Member Posts: 26
    This is a example to "merge" various .doc in one .doc:
    Variables:
    TemplatePathBlank - Text - 250
    ===========================================
    Code:
    TemplatePathBlank := 'c:\doc-1.doc';
    
    Attachment.GET(SalesSetup."Blank Template"); // this field (Blank Template) is a integer and store the attachment no. inside table #311
    
    Attachment.ExportAttachment(TemplatePathBlank);
    
    CREATE(wdApp);
    wdDoc := wdApp.Documents.AddOld(TemplatePathBlank);
    
    // type your word automation code
    
    wdSel := wdApp.Selection;
    
    wdSel.InsertFile('c:\doc-2.doc');
    wdSel.InsertBreak;
    
    wdSel.InsertFile('c:\doc-3.doc');
    wdSel.InsertBreak;
    
    wdSel.InsertFile('c:\doc-n.doc');
    wdSel.InsertBreak;
    
    // c:\doc-1.doc is a template (can be blank) and will store the others documents
    
    wdApp.Visible := TRUE;
    wdApp.ActiveDocument.Fields.Unlink;
    
    Monteiro, Rodrigo
    www.draeger-medical.com
Sign In or Register to comment.