Code: Select all
//Setup Input File:
Let>inReport=c:\reports\somereport.rpt
//Configure output file:
Let>outFile=c:\exports\somereport.pdf
//Open the report in Crystal
ExecuteFile>inReport
WaitWindowOpen>Crystal Reports - [*
WaitReady>0
//Wait while Status bar says "Formatting"
Label>IsReady
GetControlText>Crystal Reports - [*,Afx:00400000:8:00010011:00000010:00000000,1,Status
Pos>Formatting,status,1,p
If>p>0,IsReady
//Now ready to export - Send ALT-f-e-e to initiate File/Export/Export
Wait>2
Press ALT
Send>fee
Release ALT
WaitWindowOpen>Export
//In my case PDF is first option, so no need to change the option, just press Enter
SetFocus>Export
Press Enter
//Wait for next "Export Options" window to appear and press enter again
WaitWindowOpen>Export Options
SetFocus>Export Options
Press Enter
//Wait for "Choose export file" dialog and provide the output file
WaitWindowOpen>Choose export file
SetFocus>Choose export file
Send>outFile
Press Enter
//Now wait for the "Exporting Records" progress window
WaitWindowOpen>Exporting Records
//And then wait for the "Exporting Records" progress window to disappear
WaitWindowClosed>Exporting Records
//All done - quit Crystal?
SetFocus>Crystal Reports - [*
Press ALT
Press F4
Release ALT
Code: Select all
// create a text file with the following format
// inputfile1.rpt;outputfile1.pdf
// inputfile2.rpt;outputfile2.pdf
// inputfile3.rpt;outputfile3.pdf
// etc;etc
//Set path of input file here:
Let>inputFile=d:\input.txt
//this part loops through the input file, extracts each input/output pair
//and calls the DoExport subroutine to process the export
Let>k=1
Label>ReadInputLoop
ReadLn>inputFile,k,line
If>line=##EOF##,finish
Separate>line,;,parts
Let>inReport=parts_1
Let>outFile=parts_2
GoSub>DoExport
Let>k=k+1
Goto>ReadInputLoop
Label>finish
SRT>DoExport
//Open the report in Crystal
ExecuteFile>inReport
WaitWindowOpen>Crystal Reports - [*
WaitReady>0
//Wait while Status bar says "Formatting"
Label>IsReady
GetControlText>Crystal Reports - [*,Afx:00400000:8:00010011:00000010:00000000,1,Status
Pos>Formatting,status,1,p
If>p>0,IsReady
//Now ready to export - Send ALT-f-e-e to initiate File/Export/Export
Wait>2
Press ALT
Send>fee
Release ALT
WaitWindowOpen>Export
//In my case PDF is first option, so no need to change the option, just press Enter
SetFocus>Export
Press Enter
//Wait for next "Export Options" window to appear and press enter again
WaitWindowOpen>Export Options
SetFocus>Export Options
Press Enter
//Wait for "Choose export file" dialog and provide the output file
WaitWindowOpen>Choose export file
SetFocus>Choose export file
Send>outFile
Press Enter
//Now wait for the "Exporting Records" progress window
WaitWindowOpen>Exporting Records
//And then wait for the "Exporting Records" progress window to disappear
WaitWindowClosed>Exporting Records
//All done - quit Crystal?
SetFocus>Crystal Reports - [*
Press ALT
Press F4
Release ALT
End>DoExport