Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print to File (using Microsoft Word) 1

Status
Not open for further replies.

Lorski

Programmer
Dec 28, 2000
12
US
Hi!

I am using VB 6, Access 97 and Crystal 8.
I have a "Crystal Reports Control" on my VB form...and I've set it's properties to "print to file". When executed, the Crystal Report is saved in the the Word document...but the Word file has blank lines in the report. Everything is showing up...just the spacing is odd. It will print several lines...then a blank line... then several lines, etc. The file it is printing to, uses a Word 6.0 for '95 format. Obviously the lines drawn on the report aren't showing either...but I think we can deal with that. With the data broken up like this, it is hard to tell if they have a complete order. Any suggestions?

Thanks
 
Good luck honestly. My luck with saving any crystal reports to word has been pretty bad since Seagate doesn't guarantee that their formatting will work with any other programs. I found that the best bet is to save it in Rich text format (.rtf). That's about all that helps.

CrystalVisualBOracle
 
Ken,
It isn't wrapping...at least that I can see... and everything on this page is one record in the database tables. I couldn't see a true pattern either. Looks like it prints 5 lines with spacing in between, then two lines together... prints 6 lines with spacing, then two lines together.

 
I ended up creating one report to print to printer... and another report where the fields are moved around for the print file. I just moved lines around until they looked right in the print file. The print file report isn't pleasing to the eye, until it's sent to a print file. Works fine. Thanks for all the help!
 
Have you tried the following code?


Exporting using the Wrapper DLL is broken into the following API calls. These API calls are not found in any help file and are only documented in the "*.bas" file that you include in your project as mentioned above. The function declarations for these API calls and the format type constants are included in the "*.bas" file.

crPEExportToDisk - Exporting to Disk file
crPEExportToMAPI - Exporting to Mail (MAPI)
crPEExportToEXCH - Exporting to Microsoft Exchange
crPEExportToODBC - Exporting to an ODBC data source
crPEExportToHTML - Exporting to HTML format

NOTE: Any strings being passed to these functions MUST be NULL terminated.

Here is some sample code from a Visual Basic application that demonstrates how to export using these wrapper functions. Note that you don't have to fill in each variable specified, since some variables are specific to the format being exported to. The case numbers used for ExportFormat and ExportDestination are specific to this example, and are used in this manner for clarity. You can change these values if you desire.

Dim Result As Integer
Dim MainJob As Integer
Dim ExportFormat As Integer
Dim ExportDestination As Integer
Dim FormatDLLName As String
Dim FormatType As Long
Dim UseSameNumberFormat As Integer
Dim UseSameDateFormat As Integer
Dim StringDelimiter As String
Dim FieldDelimiter As String
Dim DataSource As String
Dim UserID As String
Dim Password As String
Dim TableName As String
Dim MAPIToList As String
Dim MAPICCList As String
Dim MAPISubject As String
Dim MAPIMessage As String
Dim EXCHProfile As String
Dim EXCHPassword As String
Dim EXCHFolderPath As String

ExportFormat = Select an export format
ExportDestination = Select an export destination

DataSource = ODBC data source name
UserID = Logon user id
Password = Logon password
TableName = Table name to export data to

UseSameNumberFormat = 1 or 0 for True or False
UseSameDateFormat = 1 or 0 for True or False
StringDelimiter = String delimiter for character separated value format
FieldDelimiter = Field delimiter for character separated value format

MAPIToList = Email To list
MAPICCList = Email CC list
MAPISubject = Email subject
MAPIMessage = Email message

EXCHProfile = Exchange profile
EXCHPassword = Exchange password
EXCHFolderPath = Exchange folder path

' Open print engine
Result = PEOpenEngine()
' Open the selected report
MainJob = PEOpenPrintJob("c:\myreport.rpt" & vbNullChar)
' Set FormatDLLName and FormatType based on selected format type
Select Case ExportFormat
Case 0 ' Crystal Reports
FormatDLLName = "uxfcr.dll" ' "u2fcr.dll" for 32bit
FormatType = crUXFCrystalReportType
Case 1 ' Data Interchange
FormatDLLName = "uxfdif.dll" ' "u2fdif.dll" for 32bit
FormatType = crUXFDIFType
Case 2 ' Word for Windows
FormatDLLName = "uxfwordw.dll" ' "u2fwordw.dll" for 32bit
FormatType = crUXFWordWinType
Case 3 ' Record Style
FormatDLLName = "uxfrec.dll" ' "u2frec.dll" for 32bit
FormatType = crUXFRecordType
Case 4 ' Rich Text
FormatDLLName = "uxfrtf.dll" ' "u2frtf.dll" for 32bit
FormatType = crUXFRichTextFormatType
Case 5 ' Comma Separated Values
FormatDLLName = "uxfsepv.dll" ' "u2fsepv.dll" for 32bit
FormatType = crUXFCommaSeparatedType
Case 6 ' Tab Separated Values
FormatDLLName = "uxfsepv.dll" ' "u2fsepv.dll" for 32bit
FormatType = crUXFTabSeparatedType
Case 7 ' Character Separated Values
FormatDLLName = "uxfsepv.dll" ' "u2fsepv.dll" for 32bit
FormatType = crUXFCharSeparatedType
Case 8 ' Text
FormatDLLName = "uxftext.dll" ' "u2ftext.dll" for 32bit
FormatType = crUXFTextType
Case 9 ' Paginated Text
FormatDLLName = "uxftext.dll" ' "u2ftext.dll" for 32bit
FormatType = crUXFPaginatedTextType
Case 10 ' Tab Separated Text
FormatDLLName = "uxftext.dll" ' "u2ftext.dll" for 32bit
FormatType = crUXFTabbedTextType
Case 11 ' Lotus WKS
FormatDLLName = "uxfwks.dll" ' "u2fwks.dll" for 32bit
FormatType = crUXFLotusWksType
Case 12 ' Lotus WK1
FormatDLLName = "uxfwks.dll" ' "u2fwks.dll" for 32bit
FormatType = crUXFLotusWk1Type
Case 13 ' Lotus WK3
FormatDLLName = "uxfwks.dll" ' "u2fwks.dll" for 32bit
FormatType = crUXFLotusWk3Type
Case 14 ' Excel 2.1
FormatDLLName = "uxfxls.dll" ' "u2fxls.dll" for 32bit
FormatType = crUXFXls2Type
Case 15 ' Excel 3.0
FormatDLLName = "uxfxls.dll" ' "u2fxls.dll" for 32bit
FormatType = crUXFXls3Type
Case 16 ' Excel 4.0
FormatDLLName = "uxfxls.dll" ' "u2fxls.dll" for 32bit
FormatType = crUXFXls4Type
Case 17 ' Excel 5.0
FormatDLLName = "uxfxls.dll" ' "u2fxls.dll" for 32bit
FormatType = crUXFXls5Type
Case 18 ' ODBC
Case 19 ' HTML 3.0 Draft Standard
FormatType = crUXFHTML3Type
Case 20 ' HTML 3.0 Explorer 2.0
FormatType = crUXFExplorer2Type
Case 21 ' HTML 3.0 Netscape 2.0
FormatType = crUXFNetscape2Type
End Select
' Set export options based on selected export destination
Select Case ExportFormat
Case 0 To 17
Select Case ExportDestination
Case 0 ' Export to File
Result = crPEExportToDisk(MainJob, "c:\myfilename" & vbNullChar,
FormatDLLName & vbNullChar, FormatType, UseSameNumberFormat,
UseSameDateFormat, StringDelimiter & vbNullChar, FieldDelimiter &
vbNullChar)
Case 1 ' Export to MAPI
Result = crPEExportToMapi(MainJob, MAPIToList & vbNullChar, MAPICCList &
vbNullChar, MAPISubject & vbNullChar, MAPIMessage & vbNullChar,
FormatDLLName & vbNullChar, FormatType, UseSameNumberFormat,
UseSameDateFormat, StringDelimiter & vbNullChar, FieldDelimiter &
vbNullChar)
Case 2 ' Export to Exchange
Result = crPEExportToExch(MainJob, EXCHProfile & vbNullChar, EXCHPassword
& vbNullChar, EXCHFolderPath & vbNullChar, FormatDLLName &
vbNullChar, FormatType, UseSameNumberFormat, UseSameDateFormat,
StringDelimiter & vbNullChar, FieldDelimiter & vbNullChar)
End Select
Case 18 ' Export to ODBC
Result = crPEExportToODBC(MainJob, DataSource & vbNullChar, UserID &
vbNullChar, Password & vbNullChar, TableName & vbNullChar)
Case 19 To 21 ' Export to HTML
Result = crPEExportToHTML(MainJob, FormatType, "c:\myfilename" &
vbNullChar)
End Select
' Start the print job
Result = PEStartPrintJob(MainJob, 1)
' Close the print job
PEClosePrintJob (MainJob)
' Close the engine
PECloseEngine


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top