Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Determine Line Position in a Word Doc.
Message
De
11/07/2006 21:43:33
 
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
COM/DCOM et OLE Automation
Titre:
Determine Line Position in a Word Doc.
Divers
Thread ID:
01135560
Message ID:
01135560
Vues:
74
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.
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform