Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Writing to a Word document - paragraphs
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows 7
Miscellaneous
Thread ID:
01530519
Message ID:
01530745
Views:
35
>>>Tamar
>>>
>>>Tables are doing the same thing - Word reads chr(13) (which is either the enter or shift+enter) as a new paragraph start. Any type of paragraphs.keeptogether command flies right out the window at that point.
>>
>>There's a Word setting that says start the row on a new page if it won't fit on this one, or something like that.
>>
>>Tamar
>
>the problem is in the format of each Question/Responses set. Word doesn't recognize they are together because of the Chr(13) or Chr(10) LF character. To my knowledge, without doing some jumping through hoops character count/build each full line based on spacing (and gods help me if they decide to change the font or something like that), there's no way to build these sets without using a LF character. So it ends up looking like:
>
>1. Question (LF)
> a) Response (LF)
> b) Response (LF)
> c) Response (LF)
> d) Response (LF)
>
>
>Word views every (LF) as a new paragraph and even though I tell Word to keep paragraphs together, it's a moot command because Word views each line as its own paragraph. Hence the frustration.

Hi Dorris,

I created a macro and what word does is just move the cursor in the table's cells, the code looks like this, very rough quick and dirty code :)
#DEFINE wdCell 12
*LOCAL loWord as Word.Application, loTable

loWord			= CREATEOBJECT('Word.Application')
loDocument		= loWord.Documents.Add()
loDocument.Tables.Add(loWord.Selection.Range, 6, 2)
loTable			= loWord.ActiveDocument.Tables(1)
WITH loTable
	.ApplyStyleHeadingRows = .T.
	.ApplyStyleLastRow = .F.
	.ApplyStyleFirstColumn = .F.
	.ApplyStyleLastColumn = .F.
	.ApplyStyleRowBands = .T.
	.ApplyStyleColumnBands = .F.
ENDWITH
loTable.Select()
loDocument.ActiveWindow.Selection.TypeText("1. Question")
loDocument.ActiveWindow.Selection.MoveRight(wdCell)
loDocument.ActiveWindow.Selection.TypeText("2. Question")
loDocument.ActiveWindow.Selection.MoveRight(wdCell)
loDocument.ActiveWindow.Selection.TypeText("(a) Response 1")
loDocument.ActiveWindow.Selection.MoveRight(wdCell)
loDocument.ActiveWindow.Selection.TypeText("(a) Response 2")
loDocument.ActiveWindow.Selection.MoveRight(wdCell)
loDocument.ActiveWindow.Selection.TypeText("(b) Response 1")
loDocument.ActiveWindow.Selection.MoveRight(wdCell)
loDocument.ActiveWindow.Selection.TypeText("(b) Response 2")

loWord.Visible	= .t.
"The five senses obstruct or deform the apprehension of reality."
Jorge L. Borges?

"Premature optimization is the root of all evil in programming."
Donald Knuth, repeating C. A. R. Hoare

"To die for a religion is easier than to live it absolutely"
Jorge L. Borges
Previous
Reply
Map
View

Click here to load this message in the networking platform