Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Nospace in setting in word up mail merge
Message
De
06/03/2012 08:58:57
 
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Divers
Thread ID:
01537250
Message ID:
01537375
Vues:
49
>following your example below i have come up with this - it actually passes through without errors this time around. However it does not affect the line spacing as i had hoped. do i need to define the span of pragraphs(1) or is it default for the whole document - which is what i want. btw this is not mail merge - i am simply creating a formated letter which when selected will contain the client name and other details.
>
>
>#DEFINE wdToggle 9999998
>#DEFINE wdLineSpaceSingle 0
>
>LOCAL loWord, loSelection, loDocument
>loWord = CREATEOBJECT("Word.Application")
>loWord.Visible = .T.
>loDocument = loWord.Documents.Add()
>loSelection = loWord.Selection
>loSelection.Font.Name= "CALIBRI"
>loSelection.Font.Size= 11 
>
>	with loselection.Paragraphs[1].format 
>	 .LineSpacingRule = wdLineSpaceSingle
>	endwith
>
>_cliptext=FILETOSTR("temp.txt")
>loSelection.paste()
>
First, I recommend whenever possible you work with Range instead of Selection. It's faster and more flexible. In addition, talk to the ParagraphFormat object to set the spacing.

So I'd rewrite your code (starting after you have the document) as:
loRange = loDocument.Range()
loRange.Font.Name= "CALIBRI"
loRange.Font.Size= 11 

with loRange.Paragraphformat 
	 .LineSpacingRule = wdLineSpaceSingle
endwith
All that said, though, I suspect it's the paste that's killing your format choices. You might try pasting first, then setting the whole as a range, and formatting it.

One more thought: it's likely that the text file you're pasting in has two returns after each paragraph. That's pretty typical for people typing in a text file. So you may need to replace double returns with single. Probably easier to do that with VFP code before you paste. Just use STRTRAN().

Tamar



>
>>Glad the paper's helping you. You might also be interested in the book Della Martin and I wrote on automating Office from VFP: http://www.hentzenwerke.com/catalog/autofox.htm
>>
>>For this problem, as I said, the Line object isn't what you think it is, and it's not relevant. Take a look at the LineSpacing property of the Paragraph object.
>>
>>Tamar
>>
>>>btw tamar - i am going through your article as we speak - nicely done - thanks - k
>>>could this be related to a #define .... i wonder - i have been trying to solve it through loSelection.
>>>
>>>http://www.tomorrowssolutionsllc.com/Materials/AutomatingWord.html
>>>
>>>
>>>>>I am try to get vfp to print up some form letters using mail merge - i've go this far but can't seem to change the line spacing when the document opens in Word - default is 1 line - i would like it set to 'nospace' so the signature will appear uninterrupted.
>>>>>
>>>>>i took a guess at the code - checked some sources but can't seem to find any reference to this feature. any ideas??
>>>>>
>>>>>(Apologies that i cannot credit the pro who got me this far - this code has little to do with me.) many thanks k
>>>>>
>>>>>
>>>>>#DEFINE wdToggle 9999998
>>>>>LOCAL loWord, loSelection, loDocument
>>>>>loWord = CREATEOBJECT("Word.Application")
>>>>>loWord.Visible = .T.
>>>>>loDocument = loWord.Documents.Add()
>>>>>loSelection = loWord.Selection
>>>>>loSelection.Font.Name= "CALIBRI"
>>>>>loSelection.Font.Size= "10.5"
>>>>>
>>>>>loSelection.line.nospace  &&& XXX does not work
>>>>>
>>>>>_cliptext=FILETOSTR("temp.txt")
>>>>>loSelection.paste()
>>>>>
>>>>
>>>>The Word Line object isn't what you think it is. The line spacing you're talking about is related to the Paragraph object. Check out Paragraph.LineSpacing.
>>>>
>>>>Tamar
Précédent
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform