Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Automating a mail merge
Message
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Miscellaneous
Thread ID:
01193945
Message ID:
01194044
Views:
38
In unrelated thread that I'm attempting to move here, I got a reply from Gregory Adams to my question to Marcia:

1) when printing does VFP wait for Word to complete the task or does it go on (like after the MailMerge.Execute command?)

Greg:>
It goes on and does not wait. This is what I use to have foxpro wait
#define wdDialogFilePrint                      88

with WordObj.ActiveDocument.Application.Dialogs(wdDialogFilePrint)
	.Printer = m.PrinterName
	.numcopies = 1
	.Execute()
endwith
			
#undefine wdDialogFilePrint
	    	
&&WordObj.ActiveDocument.PrintOut(FALSE,,,,,,,)
with m.WordObj.Application
	do while !empty(.BackgroundPrintingStatus)
		=sleep(2000)
	enddo
endwith
			
#define wdDoNotSaveChanges         0
			
&&WordObj.ActiveDocument.Close(wdDoNotSaveChanges)
=m.WordObj.Quit(wdDoNotSaveChanges)

#undefine wdDoNotSaveChanges
Thanks, Greg. I have also investigated having a separate data source for each document to mitigate conflicts. My original posting, shown below, details some problems with getting that done. I thought it would be easy, but what I've done in the past is associate multiple Word docs with the same data source. Trying to associate each one with its own data source proved to be more of a pain. Any thoughts you have on that would be appreciated, also.

>I automate Word to do mail merges for clients, but one client seems to be having some issues I normally don't see. First, they are doing a lot of initial printing and then the amount they do each day will taper off to some relatively small number between (guessing) 50 and 150 documents. This application is run under Terminal Services. There are about 390 documents and they have to be sent out to 3 or 4 thousand times intially. Printing started out fine, but the last couple of days they've run into locking problems (only one person is printing at the moment AFAIK). Each document uses the same Excel file for its data source. The data source is repopulated between each document, the document prints, the data source is repopulated, then the next document prints.
>
>So I thought maybe I'd use a different data source for each document. I have a program to attach a data source to a Word doc and it worked great to attach the one single data source to each document, but when attaching a different data source to each document there are problems. I've discovered that if Excel is already open when the program is run, it works much faster (60 seconds per doc when Excel is not already open and just over 5 seconds per doc when Excel is open). The problem is that altough Word did not open Excel, it did open the data source doc (the spreadsheet) and it seems it would close the data source document, too. Yet it does not and I'm left with a bunch of open Excel docs. Not that big of a deal, but I'd be left with 390 spreadsheets open in Excel and I'm not sure how my computer will handle that (can you even have that many open docs in Excel).
>
>Why the speed difference mentioned above and why is Word leaving the Excel spreadsheet file open? I'd post a code example, but I'm falling asleep at the keyboard. Please post any suggestions you have and I'll try to get some code out here.
eCost.com continues to rip people off
Check their rating at ResellerRatings.com
Previous
Reply
Map
View

Click here to load this message in the networking platform