dancing spaces !!!

Hi The following piece of code is to write text into Ms Word.I am facing some problems with the appearence of word document. Please go through to see the problem . Variables wapp Automation ‘Microsoft Word 8.0 Object Library’.Application wrange Automation ‘Microsoft Word 8.0 Object Library’.Range char Char word Text 30 CLEAR(wapp); CREATE(wapp) ; wapp.Visible(TRUE); wapp.Documents.Add(); char := 11; word := FORMAT(char); wrange := wapp.ActiveDocument.Range(); wrange.InsertAfter(‘This_line_contains_10_spaces 10spaces’); //there are 10 spaces between the letters 10_spaces and 10spaces wrange.InsertAfter(word) ; wrange.InsertAfter(‘This_have_19_spaces 19spaces’); ////there are 19 spaces between the letters 19_spaces and 19spaces Please note that both the words have 47 letter each. This code is working and it put two lines in word document. But the appearence of these 2 lines in the word document are different I have noted the following things in word document. Both the lines are started from the same XPos. But the words “10spaces” and “19spaces” are not seen to be started on same XPos. The word '19spaces are started little earlier(2 or 3 letters) than that of word ‘10spaces’. Why is that ? Is it true that, space character take less space than other characters ? Is anybody experienced this problem ? How we can overcome this ? Regards Joseph Mathew

The problem is caused 'cos you’re using a non-fixed size font. Try using a fixed one (like courier) and you’ll note the difference. In non-fixed size fonts the different characters have diferent sizes (width) depending in how many pixels they require for being shown. Regards from Spain – Alfonso Pertierra apertierra@teleline.es Spain

The most common used fonts in are nowadays of the proportional type, which means that each character is having a different width. To see the difference, put a series of iiiii’s under a series of wwww’s. The space is having, just like any other character, its own width and you can be sure you can’t use this for proper justifications of text columns. The correct way is to use tabs (Chr = 9), whereby the rightjustifying tab type is great for creating columns of numbers, or decimal tabs for lining up amounts. The other alternative is to use a monospaced font (all characters are having an equal width), but Courier and the like look very oldfashioned. John

I haven’t done this from Navision, but I used to do it all the time from SAS. If you need to position your text in certain columns, why don’t you create a Word table? The columns and rows can be dynamically assigned according to the data being presented. And if you don’t want to see the separator characters, they can be turned off.

Hi As suggested by Matt Benvenuti the best solution is to create word table. But I am facing some problem in table creation. When I have tried to create a second table it gives error. Please have a look on the follwing code. wrange := wapp.ActiveDocument.Range(); wapp.ActiveDocument.Tables.Add (wrange,9,3); //code for inserting text to the //first table //then create II table wapp.ActiveDocument.Tables.Add(wRange,1,5); Through this code the first table have created successfully. However, while creating the Second table it gives an error stating ‘Already have one table in this position’. I think this problem is relating with range object. I have tried some other way but can’t resolve this problem so far. How can I create two or more tables in word document ? Pl. help me to sort out this problem. Regards Joseph Mathew Edited by - joseph_mathew on 2001 Jul 12 10:25:16

This is completely from memory, but I think it’s right. What I used to do is have a Word template, with the text mostly completed. The template contained a series of bookmarks. You need to move the Word pointer from inside Navision to the Bookmark where you want to create the table. Then add the table. Otherwise, (I think) you will only ever be able to write to the beginning of the document. Lke I previously stated, I haven’t done this in over 3 years, so don’t shoot me if I’ve forgotten a step. cheers,

We can insert tables in word using the following code wRange.InsertParagraphAfter ; intWordPosistion := wApp.ActiveDocument.Words.Count; wRange := wApp.ActiveDocument.Words.Item(intWordPosistion); wApp.ActiveDocument.Tables.Add(wRange,1,5); Regards Joseph Mathew