Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
File in Use Question
Message
 
To
14/09/1998 11:41:21
Cetin Basoz
Engineerica Inc.
Izmir, Turkey
General information
Forum:
Visual FoxPro
Category:
Other
Miscellaneous
Thread ID:
00135468
Message ID:
00136236
Views:
26
>>Cetin,
>>The users of my software are very old, 70+ years. ODBC is not the way to go. Using excel, or maybe I should think of a delimited file, would be much better. I'm thinking most will use Word 95 or 97 but I can't guarantee that either. I want them to simply use the 'Insert Merge Field' thinking this would be the easiest for them. I'm not going to support this anyway. Only give them the location and the name of the file. If they know how to create a merge, then fine. I don't want to be on the phone with these gentlemen for extended periods time.
>>
>>P.S.
>>Maybe, when I installed Word, I didn't put in all the filters. DBF did not show up as one of the options for the merge records, I don't know.
>>
>>I guess it boils down to, should I use .xls or delimited text file? I picked .xls but I'm having second thoughts.
>>
>>Robert
>Hi Robert,
>It was the first thing I noticed (elderly people) and for that reason didn't hack much at the beginning. Now first I'll provide you a basic code here, tell me what you think and we can goon further. OK ? :
**************************************************
>* Start of code
>**************************************************
>select * from (home()+"samples\data\customer") into cursor wrdTest
>* Replace with your select for invoice
>_VFP.datatoclip(alias(),reccount(),3) && Copy VFP table to clipboard
>* This part is for changing headers later in word
>local ix
>local array aNewFieldNames[fcount()] && Will change some headers later
>for ix=1 to fcount()
>    aNewFieldNames[ix] = field(ix)
>* dbgetprop(alias()+"."+field(ix),"Field","Caption") is a shorcut
>endfor
>aNewFieldNames[1] = "Customer Id"
>aNewFieldNames[2] = "Company Name"
>aNewFieldNames[3] = "Pls Contact To"
>use in "wrdTest"  && No need anymore
>* This part is for changing headers later in word
>PUBLIC oWordDocument
>
>*** set the LOCALEID to English
>nlLocaleId=sys(3004)	&& Save local id
>=sys(3006,1033)			&& We will be sending instructions in English
>
>wait window nowait "Creating Word Document..."     && Inform user
>oWordDocument=createobject("word.basic")	&& Create word object
>
>with oWordDocument
>	.appshow			&& Show word app
>	.filenewdefault     && New file, default template - this is our main doc
>	* If you have a predefined doc template
>	* then instead of filenewdefault - fielopen(cTemplateDoc)
>	.MailMergeCreateDataSource("c:\temp\xmergedoc")  && Create datasource
>	.MailMergeEditDataSource	&& Edit data source
>	.editselectall		&& Select entire doc - has default fields now
>	.editpaste  		&& Clipboard data pasted to word - paste over
>	.editfind(" ","",0,0,0,0,0,0,,1,,1)
>* Remove spaces - otherwise header fail
>	.editselectall		&& Select entire doc
>	.texttotable(1)		&& Convert text to table - tabs (1) (Word table)
>	.editgoto("\StartOfDoc")	
>* Go to predefined bookmark  - Start of doc
>	.editgoto("\Table")	
>* Go to predefined bookmark \Table - Start of table
>	.nextcell
>	.prevcell		&& .nextcell .prevcell to select first cell
>	for ix=1 to alen(aNewFieldNames)
>    	.insert(aNewFieldNames[ix])
>    	.nextcell
>	endfor
>	.tabledeletecolumn  && Delete extra column
>	.MailMergeEditMainDocument	&& Activate the main document
>* Now you have "MailMerge" toolbar and at the very left "Insert Merge field tab"
>* You can also insert a merge field programmatically
>* .InsertMergefield("address")
>endwith
>
>**** Set the LocaleId to the previous value
>=sys(3006,val(nlLocaleId))
>
>**************************************************
>* End of code
>**************************************************
Cetin

Cetin,

I appreciate the code, I've got some word basic commands I've used before and its always nice to get more examples. Sometimes its difficult to determine what command does what without much experimentation. (I don't get MSDN and very few books.)

I can not guarantee the users will have Word or any other word processing software, nor can I even guess the version. I've thought a great deal about creating word automation but decided against it. I'd only be begging for trouble. I am talking about Secretaries for Mason's. These are volunteer officers, many very old. I have 24 copies of my software in BETA 1 right now, I've received a request to add the ability to do mail merges. I think including the file and its location will be sufficient. If a Secretary knows how to use it, fine, if not, then I won't support it anyhow nor will I give instructions for its use.

Thanks for your imput though. I'm going to copy your code above and add it to my cheat sheet for word automation.

Robert.
Previous
Next
Reply
Map
View

Click here to load this message in the networking platform