Word Automation Puts Table Over the Document Title
Matt.Hill
Member Posts: 32
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:
The heading is thus:
I'm using the following to generate the table:
Thanks!
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!
0
Comments
-
Lucky gues : Cant you do
wrdSelection.Tables.Add
instead of
wrdRange.Tables.Add
Regards, Jan-PieterIn a world without Borders or Fences, who needs Windows and Gates?0 -
First thing I tried, and gives the same result....0
-
And this ... ? The first parameter of the add function looks like a pointer to some place in the document. Try changing that in various ways. I dont think the add function takes the cursor position at all.
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 luckIn a world without Borders or Fences, who needs Windows and Gates?0
Categories
- All Categories
- 73 General
- 73 Announcements
- 66.7K Microsoft Dynamics NAV
- 18.8K 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
- 328 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