Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
Word docs don't get printed to disk
Message
 
 
To
All
General information
Forum:
Visual FoxPro
Category:
COM/DCOM and OLE Automation
Title:
Word docs don't get printed to disk
Environment versions
Visual FoxPro:
VFP 9 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
MS SQL Server
Miscellaneous
Thread ID:
01529097
Message ID:
01529097
Views:
69
I have an application that allows the user to select multiple documents, a mix of Word (with or without editing) and VFP reports, and print them to printer, PDF, or disk (for release later in a 'batch' process.) I've recently discovered that when printing to disk/batch, only the first document selection actually gets written to a disk file. This app has been running for many years and no one has complained, but while testing a new feature, it came to my attention right away!

The process works like this: the user selects a group of documents and sends them to the desired destination--Batch (a disk file), Printer, or PDF. There are separate automation servers to handle VFP, Word with editing, and Word without editing. When Word documents are to be edited, the server handles one at a time (a new server is created for each document.) But when no editing is required, an array of documents is passed to the server and it and cycles through the array twice, first merging the data into the templates, and then printing each document in turn. It is in this second server where the problems crop up. The individual documents are perfectly formed. They can be printed to disk interactively, but when printing under automation, second and subsequent documents either don't make it to disk at all or have a size of 0. In tracing through the process, the error (1426 - 'OLE error code 0x"name". ) occurs on this line:
oWord.ActiveDocument.Printout(.f.,.f.,0,cPrnName,,,,nCopies)
The documents have temporary names in Word ('Document1','Document2;, etc.) since the merged documents are never saved, and cPrnName is the unique name assigned to the disk file. Background printing is off during the process, hoping to force the tasks to occur in real time.

Has anyone actually printed multiple documents to disk from an automation server in this fashion? The code works perfectly when printing to Printer or PDF. I can't understand why the client hasn't complained about the missing documents!
Reply
Map
View

Click here to load this message in the networking platform