I'm trying to create a report that is passed to Word. Each page is titled with the Customers name, and there is a table below this which details their current order.
However, when the table is produced, having placed the Customers name at the top of the page and moved down two lines to place the table at that point the cursor is moved back to the top of the page and the title is over-written with the table!
How to I get the table to be inserted at the cursor's current line...?
The declarations are:
WrdApp.Documents.Add; // new blank page
WrdRange := WrdApp.ActiveDocument.Range;
wrdSelection := WrdApp.Selection;
WrdRange.Font.Size := 10;
The heading is thus:
wrdSelection.Font.Italic(1);
wrdSelection.TypeText('Customer: ' + Customer."No." + ' ' + Customer.Name);
wrdSelection.Font.Italic(0);
wrdSelection.TypeParagraph;
wrdSelection.TypeParagraph;
I'm using the following to generate the table:
wrdTable := WrdRange.Tables.Add(WrdRange,(Rows + 1),Collumns);
Thanks!
Comments
wrdSelection.Tables.Add
instead of
wrdRange.Tables.Add
Regards, Jan-Pieter
wrdTable := WrdSelection.Tables.Add(wrdSelection.Range, (Rows + 1), Collumns);
You could also make a template document, place a table on it and open this. Then you make a pointer to the table like this:
wrdTable := WrdSelection.Tables.Item(0);
I think that will be a lot easier.
You can also try recording a macro in VBA. Then add the table while recording. When done look in the macro designer (ALT+F11) and steal the code it has generated for you. Try to translate it to C/AL.
Good luck