Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Determine Line Position in a Word Doc.
Message
From
11/07/2006 21:53:06
 
 
To
11/07/2006 21:43:33
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
01135560
Message ID:
01135561
Views:
15
Line numbers are meaningless when using proportional fonts. How will you determine how many lines if the text uses different sized fonts?

>I'm using automation to create a word doc from VFP 8 (Word version = 2002).
>I open an existing document, then add text to it. What I'd like to do is determine the current line number of the current page in the Word document so I can include a page break, if necessary. My code looks like this:
>
>loWord = CREATEOBJECT("Word.application")
>WITH loWord
>  .Documents.Open("DocToOpen.doc")
>
>  WITH .ActiveDocument
>    *Grab a reference to the existing text.
>    loSelection = .ActiveWindow.Selection
>    WITH loSelection
>      	*Add Customer name and billing address.
>      	.InsertAfter(lcCustName + CHR(13))
>      	.InsertAfter(lcAddr1 + CHR(13))
>	IF !EMPTY(lcAddr2)
>	    .InsertAfter(lcAddr2 + CHR(13))
>	ENDIF
>	.InsertAfter(lcCityStZip + CHR(13) + CHR(13))
>
>	*Add salut, and default text
>       	.InsertAfter(lcSalut + "," + CHR(13))
>        .InsertAfter("Some introductory text goes here:" + CHR(13))
>      	*Then move down one line.
>      	.MoveDown(,1,)
>	*Scan the cursor and add items as necessary.
>	SELECT TestCursor
>	SCAN
>	    *Check where we are on the page...need a minimum of 4 lines.
>	    If (There isn't enough space, this is the code I need)
>                *Add a page break.
>		.InsertBreak(0)			
>	    Endif
>	    .InsertAfter(FieldValue1 + CHR(13))
>	    .InsertAfter(FieldValue2 + CHR(13))
>	    .InsertAfter(FieldValue3 + CHR(13))
>	    .InsertAfter(FieldValue4 + CHR(13))				
>        ENDSCAN
>     ENDWITH
>  ENDWITH
>ENDWITH
>
>I've tried a whole series of object and method combinations but haven't been able to locate the one for line numbers. Paragraphs, yes, but line numbers, no. I also realize there are other ways to do what I'm trying to do. I'm open to any suggestions, as long as they move me in the right direction. Thanks in advance.
Craig Berntson
MCSD, Microsoft .Net MVP, Grape City Community Influencer
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform