Calling MS Word from a report

rsaritzkyrsaritzky Member Posts: 469
edited 2001-06-21 in Navision Financials
Hi:

I have a client where each invoice includes a 2-page cover letter (invoices are for annual membership fees). The text of this letter changes, so I'd prefer not to create all the text inside a Navision report.

Has anyone been able to call MS Word from inside a report or codeunit, and pass name and address information (more than 128 characters) and the name of an MS Word document template, and then have Word print the document and return control to Navision?

They print about 300 invoices at a time (once a month), so performance has to be fairly decent.


TIA


Ron Saritzky
email ron@scs-accounting.com
Ron

Comments

  • mfabianmfabian Member Posts: 187
    There are several steps required:

    1.) In your WinWord Doc you need to create a Macro "NavisionPrint" which takes a Merge-file (FinMerge.Txt) and creates and prints a merge document:

    Sub NavisionPrint()
    '
    ' Navision Makro
    ' Makro erstellt am 31.07.98 von Marcus Fabian
    '
    WordBasic.ScreenUpdating 0

    Set Hauptdokument = ActiveDocument
    If ActiveDocument.MailMerge.DataSource.Name = "" Then
    ActiveDocument.MailMerge.CreateDataSource Name:="C:\Temp\FinMerge.TXT"
    End If
    ActiveDocument.MailMerge.Destination = wdSendToPrinter
    ActiveDocument.MailMerge.Execute
    Hauptdokument.Close SaveChanges = wdDoNotSaveChanges
    End Sub

    2) In Navision you create the merge-file in Ascii-Format which contains Names and addresses. (in the example: C:\Temp\FinMerge.TXT)


    3) After that you simply call WinWord and pass the Macroname and the Filename:

    SHELL ('C:\Office\WinWord.EXE /m NavisionPrint /t "C:\My Documents\MemberInvoice.DOC"');

    Have fun!

    Marcus

    P.S.: About the Word Macro:
    You don't want to print but ...

    ... merge into new Document:
    ActiveDocument.MailMerge.Destination = wdSendToNewDocument

    ... e-mail the document to the e-mail address which is contained in Merge-field "EMail":
    ActiveDocument.MailMerge.MailAddressFieldName = "EMail"
    ActiveDocument.MailMerge.Destination = wdSendToEmail

    ... FAX the document to the FAX Number which is contained in Merge-field "FAX":
    ActiveDocument.MailMerge.MailAddressFieldName = "FAX"
    ActiveDocument.MailMerge.Destination = wdSendToFax


    [This message has been edited by fabian (edited 21-06-2001).]

    [This message has been edited by fabian (edited 21-06-2001).]
    With best regards from Switzerland

    Marcus Fabian
Sign In or Register to comment.