Thanks your Brill I have sorted what I wanted it to do now.
thanks for all your time it is really appreciated.
here is my code.
Dim crApp As New CRAXDRT.Application
Dim crRep As CRAXDRT.Report
Dim MyReport As String
Dim OldDefaultPrinter As String
Private Declare Function WriteProfileString Lib "kernel32" _
Alias _
"WriteProfileStringA" _
(ByVal lpszSection As String, _
ByVal lpszKeyName As String, ByVal lpszString As String) As Long
Private Declare Function SendMessageTimeout Lib "user32" Alias _
"SendMessageTimeoutA" (ByVal hwnd As String, ByVal _
msg As String, ByVal wParam As String, ByVal lParam _
As String, ByVal fuFlags As String, ByVal uTimeout As _
String, lpdwResult As String) As String
Private Sub cmdOpenCrystalReport_Click()
' load a standalone report created in the designer
Set crRep = crApp.OpenReport(File1.Path & "\" & MyReport)
CRViewer91.EnableExportButton = True
CRViewer91.ReportSource = crRep
crRep.VerifyOnEveryPrint = True
'crRep.RecordSelectionFormula = "{MyTable.MyField} = 'test';"
' print preview
CRViewer91.ViewReport
End Sub
Private Sub print_click()
'Save default printersettings.
OldDefaultPrinter = Printer.DeviceName & "," & Printer.DeviceName & "," & Printer.Port
'Show windows Printers
On Error GoTo Cancel:
ComDlg1.ShowPrinter
'Printer the Crystal Report out using viewer print options
CRViewer91.PrintReport
' Calls the Kernel32 to set back default printer
Call WriteProfileString("windows", "device", OldDefaultPrinter)
Call SendMessageTimeout(HWND_BROADCAST, WM_WININICHANGE, 0, "windows", SMTO_NORMAL, 1000, 0)
Cancel: MsgBox "it not working"
End Sub
Private Sub Drive1_Change()
Dir1.Path = Drive1.Drive
End Sub
Private Sub Dir1_Change()
File1.Path = Dir1.Path
End Sub
Private Sub File1_Click()
MyReport = File1.FileName
End Sub
Private Sub Form_Load()
Screen.MousePointer = vbHourglass
Screen.MousePointer = vbDefault
End Sub
Private Sub Form_Resize()
CRViewer91.Top = 0
CRViewer91.Left = 0
CRViewer91.Height = ScaleHeight
CRViewer91.Width = 7500
End Sub
Could somebody tell me why the heck I manage to get everything sorted out and then my printing just stops working???
Its enought o drive a girl to tears.