This is vijay from india. Can any one help me in , how to create Word Report using "Word Automation" like Excel. As i got an urgent "word report" from my client as a new requirement. Pls Help me..............
Word automation is not that difficult. Mailmerge is a whole different story.
I think you'll have to decide what you want to do.
For simple Word Automation:
//*** I use these variables:
Name DataType Subtype Length
wrdApp Automation 'Microsoft Word 11.0 Object Library'.Application
wrdDoc Automation 'Microsoft Word 11.0 Object Library'.Document
wrdSel Automation 'Microsoft Word 11.0 Object Library'.Selection
wrdTable Automation 'Microsoft Word 11.0 Object Library'.Table
wrdColumn Automation 'Microsoft Word 11.0 Object Library'.Column
wrdRange Automation 'Microsoft Word 11.0 Object Library'.Range
//*** Here is some code:
//***** Init a word document
IF ISCLEAR(wrdApp) THEN
CREATE(wrdApp);
wrdDoc := wrdApp.Documents.Add;
wrdSel := wrdApp.Selection;
//***** Insert Text
wrdSel.TypeText(ptxtText);
wrdSel.TypeParagraph;
//***** Insert a Title
wrdSel.Font.Bold := 1;
wrdSel.Font.Underline := 1;
wrdSel.TypeText(ptxtText);
wrdSel.Font.Bold := 0;
wrdSel.Font.Underline := 0;
//***** Insert a table
InsertTable(pintRows : Integer;pintCols : Integer)
wrdRange := wrdSel.Range;
wrdTable := wrdDoc.Tables.Add(wrdRange,pintRows,pintCols);
.
.
.
If you just run a macro, record of what you want to accomplish in code, then view the code in VBA, then you can use this code in C/SIDE (converting to C/AL).
For Mailmerge:
I advise you to study codeunit 5054 thoroughly. You can learn many things of this codeunit.
I prefer the mailmerge-methodology, because this gives the opportunity to work with templates. If you want to use the simple method, then the design is changed "in code".
Comments
plz help :shock:
I think you'll have to decide what you want to do.
For simple Word Automation:
If you just run a macro, record of what you want to accomplish in code, then view the code in VBA, then you can use this code in C/SIDE (converting to C/AL).
For Mailmerge:
I advise you to study codeunit 5054 thoroughly. You can learn many things of this codeunit.
I prefer the mailmerge-methodology, because this gives the opportunity to work with templates. If you want to use the simple method, then the design is changed "in code".
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog
Eric Wauters
MVP - Microsoft Dynamics NAV
My blog