Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
V6s5, Word2K, Create Letter (not mail merge) from given
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Miscellaneous
Thread ID:
00822541
Message ID:
00823435
Views:
30
Thanks. I will lookup Word Visual Basic Help and I am trying to search for word constants in the downloads. I will also try the macro recording and hope I can make head or tail of the VBA script.

Thanks for all your help, trouble you if I get struck.

>Do not feel guilty: we all are in the very same boat in the MS sea of uncertaincy. For instance, trying to reproduce the example (I gave you) with Word97 I was surprised to learn, that
>oWOrd.Selection.Range.Font.color=RGB(0,255,0) does not work there. Instead colorindex property should be used.
>How did I find it? BAsically there are two ways:
>1. You can record a macro in Word and then analyze the code and translate it to VFP.
>2. In VFP7 and above you can type from command window:
>?oWOrd.Selection.Range.Font. to see available properties, and if you type
>?oWOrd.Selection.Range.Font.colorindex= , then you see the available values of this property.
>
>And all Word constants you can find in the download section here, I believe.
>And the Word Object hierarchy you can find in the MS WOrd Visual Basic Help:
>from Word, ALT+F11->Help.
>
>So now to your question.
>To align the text you may use oWord.Selection.ParagraphFormat.Alignment property.
>If you have two text pieces on the very same line, then probably you could format this particular line to two-columns and align them differently, or convert text to table and do alignment as needed. Try to record a macro to see what is better for you.
>
>
>>This was a great example and I really appreciate your help. Now i am stuck at the following:
>>
>>
	WITH .activedocument.content
>>		.insertafter("Ref.: " + lcrefno)
>>	ENDWITH
>>
>>	.SELECTION.EndKey(wdStory)
>>	
>>	WITH .SELECTION.RANGE
>>		.style = 0
>>		.style = 1
>>		.style = 2
>>		.style = 3
>>		.style = 4
>>		.style = 5
>>		.style = 6
>>		.style = 7
>>		.style = 8
>>		.style = 9
>>		.style = 10
>>	ENDWITH
>>
>>Which style will work, none of the above do. I needed right aligning the text. Also what if there is 2 pieces of text on a line one left and the other right aligned.
>>
>>Is there any documentation to refer where I can find the properties. I feel guilty to keep on troubling you so, even after you have given me such a fine example.
>>
>>Please advise.
>>
>>>Please follow this example. It should cover your both latest questions
>>>
>>>>
>>>crlf = CHR(13)+CHR(10)
>>>
>>>wdStory=6
>>>wdExtend =1
>>>wdSectionBreakNextPage=2
>>>wdHeaderFooterPrimary=1
>>>Wdheaderfooterfirstpage=2
>>>
>>>oWord = CREATEOBJECT("Word.Application")
>>>
>>>with oWord
>>>	.documents.ADD()
>>>	.visible=.t.
>>>
>>>	with .activedocument.content
>>>		.insertafter("Test procedure:"+crlf+crlf)
>>>	endwith
>>>	
>>>	.Selection.EndKey(wdStory)
>>>	
>>>	with .activedocument.content
>>>		.insertafter("Text Line1 Font Bold Red Courier New " +crlf)
>>>	endwith	
>>>    .Selection.EndKey(wdStory, wdExtend)
>>>	WITH .Selection.Range.Font
>>>		.NAME = "Courier New"
>>>		.bold = .T.	
>>>		.color=RGB(255,0,0)
>>>	ENDWITH
>>>	
>>>    .Selection.EndKey(wdStory)
>>>
>>>* start another section, needed only to use different footer-headers in the future
>>>	.Selection.InsertBreak(wdSectionBreakNextPage)
>>>
>>>    .Selection.EndKey(wdStory)
>>>
>>>	with .activedocument.content
>>>		.insertafter("Text Line2 Font Green Times New Roman " +crlf)
>>>	endwith	
>>>    .Selection.EndKey(wdStory, wdExtend)
>>>	WITH .Selection.Range.Font
>>>		.NAME = "Times New Roman"
>>>		.bold = .f.	
>>>		.color=RGB(0,255,0)
>>>	ENDWITH
>>>    .Selection.EndKey(wdStory)
>>>
>>>    .Selection.EndKey(wdStory)
>>>
>>>* HEADER FOOTER
>>>	.ActiveDocument.PageSetup.DifferentFirstPageHeaderFooter = .f.
>>>
>>>	with .ActiveDocument.Sections(1)
>>>		.Headers(wdHeaderFooterPrimary).Range.Text = "1Header text"
>>>		.Footers(wdHeaderFooterPrimary).Range.Text = "1Footer text"
>>>	endwith
>>>
>>>	with .ActiveDocument.Sections(2)
>>>		.Headers(wdHeaderFooterPrimary).LinkToPrevious = .f.
>>>		.Footers(wdHeaderFooterPrimary).LinkToPrevious = .f.
>>>		.Headers(wdHeaderFooterPrimary).Range.Text = "2Header text"
>>>		.Footers(wdHeaderFooterPrimary).Range.Text = "2Footer text"
>>>		.Footers(wdHeaderFooterPrimary).Range.Font.Color=RGB(100,200,50)
>>>
>>>	endwith
>>>
>>>	.activedocument.SAVEAS("c:\myword.doc")
>>>	.activedocument.CLOSE
>>>endwith
>>>
>>>oWord.QUIT()
>>>oWord=.null.
>>>release oWord
>>>>
>>>
>>>>Hi Yuri. Thanks for your help.
>>>>
>>>>I have a yes and no kind of situation. The following line gives an error:
>>>>
>>>>>lnstart=.Range.Start
>>>>
>>>>Message: Member RANGE does not evaluate to an object.
>>>>
>>>>I am able to use the following line:
>>>>
>>>>.insertafter("this is the text")
>>>>
>>>>Please advise. I am using Word2K for this. What am I doing wrong.
Regards
Bhavbhuti
___________________________________________
Softwares for Indian Businesses at:
http://venussoftop.tripod.com
___________________________________________
venussoftop@gmail.com
___________________________________________
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform