keepingbusy
Programmer
Hello
I am using the code below (some of which has been edited / removed) to create a WORD document and add some records to it from a table.
The fields INFOTEXT and ACTIONTEXT are both MEMO fields. When they are shown on the word document they start off with an indent as shown below but the second line of the MEMO field (which more often than not, is more than one line) starts more to the left than in line with the first line (I hope that makes sense).
The layout looks something like this when the word document opens (but is restricted here because of the way Tek-Tips displays it). The first four lines are tabbed over, as is the first row of the MEMO field but subsequent lines from the MEMO are not tabbed
1. An area somewhere
Time created: 10:06 on 16/08/2012 by Jeff Smith
Description of item
United Kingdom
Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record...
My question is two fold:
1. How do I get the memo field to line up with the words "An", "Time", "Description" etc?
2. If possible, can I put the MEMO fields in a table cell (if that is a more efficient process)?
I am aware of how to create a table with cells:
I am also aware of setting border lines (add or remove them):
So if 2 is more efficient than 1, I can add a table/cell and remove the border and perhaps encase the memo field inside the cell to make it line up and be "Tabbed over" for the full contents of the MEMO fields as it should be.
Any advice would be appreciated
Thank you
I am using the code below (some of which has been edited / removed) to create a WORD document and add some records to it from a table.
Code:
#DEFINE vfpCR CHR(13)
#DEFINE vfpTAB CHR(9)
#DEFINE wdSeparateByTabs 1
#DEFINE wdTableFormatColorful2 9
#DEFINE wdAlignParagraphLeft 0
LOCAL loWord, loDoc, loRange, lcTable, lcField, i
* Create the document
loWord = CREATEOBJECT("Word.Application")
loWord.Visible = .T.
loDoc = loWord.Documents.Add()
WITH loWord
.ActiveDocument.PageSetup.Orientation=0
.selection.PageSetup.TopMargin = 21.5
.selection.Font.Size=18
.selection.Font.Bold=.T.
.selection.ParagraphFormat.Alignment=1 && CENTER ALIGN
.selection.typetext("MY TITLE HEADER"+vfpCR)
ENDWITH
* Add the records to the document
USE MYTABLE ORDER MYORDER
SCAN
WITH loWord
IF SHOWTHIS="Y"
.selection.typetext(vfpTAB+ ;
"Item created: "+TIMECREATE+" on "+ ;
dtoc(DATECREATE)+ ;
" by "+alltrim(proper(CREATOR))+vfpTAB+vfpCR)
.selection.typetext(vfpTAB+"Type: "+ ;
alltrim(DESCTYPE)+vfpCR)
.selection.typetext(vfpTAB+"Area: "+ ;
alltrim(AREA)+vfpCR)
ELSE
.selection.Font.Bold=.T.
.selection.typetext(vfpTAB+ ;
"No match in this area"+vfpCR)
.selection.Font.Bold=.F.
ENDIF
* Other code similar to above here... (edited)
IF NOT EMPTY(INFOTEXT)
.selection.typetext(vfpTAB+"Information: "+ ;
alltrim(infotext)+vfpCR)
ENDIF
IF NOT EMPTY(ACTIONTEXT)
.selection.typetext(vfpTAB+"Action required: "+ ;
alltrim(actiontext)+vfpCR)
ENDIF
ENDWITH
* Now add a row of - to show end of record
WITH loWord
.selection.ParagraphFormat.Alignment=1 && CENTER ALIGN
.selection.typetext(REPLICATE(CHR(45),142)+vfpCR)
.selection.ParagraphFormat.Alignment=0 && LEFT ALIGN
ENDWITH
ENDSCAN
The fields INFOTEXT and ACTIONTEXT are both MEMO fields. When they are shown on the word document they start off with an indent as shown below but the second line of the MEMO field (which more often than not, is more than one line) starts more to the left than in line with the first line (I hope that makes sense).
The layout looks something like this when the word document opens (but is restricted here because of the way Tek-Tips displays it). The first four lines are tabbed over, as is the first row of the MEMO field but subsequent lines from the MEMO are not tabbed
1. An area somewhere
Time created: 10:06 on 16/08/2012 by Jeff Smith
Description of item
United Kingdom
Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record, Text in memo field associated with this record...
My question is two fold:
1. How do I get the memo field to line up with the words "An", "Time", "Description" etc?
2. If possible, can I put the MEMO fields in a table cell (if that is a more efficient process)?
I am aware of how to create a table with cells:
Code:
oTable=oWord.ActiveDocument.Tables.Add(oRange,1,1) && Change oRange for more rows/columns
I am also aware of setting border lines (add or remove them):
Code:
.Borders.InsideLineStyle=.T.
So if 2 is more efficient than 1, I can add a table/cell and remove the border and perhaps encase the memo field inside the cell to make it line up and be "Tabbed over" for the full contents of the MEMO fields as it should be.
Any advice would be appreciated
Thank you