Calling MS Word from a report

rsaritzky
Member Posts: 469
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
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
0
Comments
-
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 Fabian0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.6K Microsoft Dynamics NAV
- 18.7K NAV Three Tier
- 38.4K NAV/Navision Classic Client
- 3.6K Navision Attain
- 2.4K Navision Financials
- 116 Navision DOS
- 851 Navision e-Commerce
- 1K NAV Tips & Tricks
- 772 NAV Dutch speaking only
- 617 NAV Courses, Exams & Certification
- 2K Microsoft Dynamics-Other
- 1.5K Dynamics AX
- 320 Dynamics CRM
- 111 Dynamics GP
- 10 Dynamics SL
- 1.5K Other
- 990 SQL General
- 383 SQL Performance
- 34 SQL Tips & Tricks
- 35 Design Patterns (General & Best Practices)
- 1 Architectural Patterns
- 10 Design Patterns
- 5 Implementation Patterns
- 53 3rd Party Products, Services & Events
- 1.6K General
- 1.1K General Chat
- 1.6K Website
- 83 Testing
- 1.2K Download section
- 23 How Tos section
- 252 Feedback
- 12 NAV TechDays 2013 Sessions
- 13 NAV TechDays 2012 Sessions