Solution alanbr00 Posted October 8, 2022 Solution Posted October 8, 2022 (edited) Hi, i'm trying to use an alternative to FileOpenDialog, FileOpen would work for me, but i can't get it work in this script. expandcollapse popup#include <GUIConstants.au3> AutoItSetOption("WinTitleMatchMode", 2) Dim $sReportName Dim $objCRApp Dim $objCRReport Dim $objCRViewer Dim $CrystalExportOptions Dim $ExportFileName Dim $ExportType ;~$sReportName = FileOpenDialog("C:\test\zNC\engine\Vinhos\VinhosTotal", "", "RPT (*.rpt)", 3);Filter "." means all $sReportName = FileOpen("C:\test\zNC\engine\Vinhos\VinhosTotal.rpt", "0") $objCRApp = ObjCreate("CrystalRuntime.Application.11") If $objCRApp = 0 Then MsgBox(0, "Error", "Could not create CrystalRuntime Application Object") Exit EndIf $objCRReport = $objCRApp.OpenReport($sReportName) If $objCRReport = 0 Then MsgBox(0, "Error", "Could not open report: " & $sReportName) Exit EndIf $objCRViewer = ObjCreate("CrystalReports11.ActiveXReportViewer.1") ; Create a simple GUI for our output ;~ $hndReportViewer = GUICreate ( "Embedded Crystal Reports Export test", 640, 580,(@DesktopWidth-640)/2, (@DesktopHeight-580)/2 , $WS_OVERLAPPEDWINDOW + $WS_VISIBLE + $WS_CLIPSIBLINGS) ;~ If $hndReportViewer = 0 Then ;~ MsgBox(0, "Error", "Could not create Window to display Crystal Reports control") ;~ Exit ;~ EndIf ;Creates an ActiveX control in the GUI. ;~ $GUIActiveX = GUICtrlCreateObj ( $objCRViewer, -1, -1, 640, 580) ;~ If $GUIActiveX = 0 Then ;~ MsgBox(0, "Error", "Could not create ActiveX Control in GUI") ;~ Exit ;~ EndIf ;~ GUICtrlSetResizing ( $GUIActiveX, $GUI_DOCKAUTO) ; Show GUI ;~ GUISetState () $objCRViewer.ReportSource = $objCRReport ; Display the Report to watch automation $objCRViewer.ViewReport ; The report displays a "0" in control 20005 while the report is loading While ControlGetText("Embedded Crystal Reports printing test", "", 20005) = "0" Sleep(250) WEnd $CrystalExportOptions = $objCRReport.ExportOptions $ExportFileName = "C:\ERPSystem\zNC\engine\Vinhos\ExportedReport.PDF" $ExportType = 31 $CrystalExportOptions.DiskFileName = $ExportFileName $CrystalExportOptions.FormatType = $ExportType $CrystalExportOptions.DestinationType = 1 $objCRReport.Export ( False ) Sleep(500) WinWaitClose("Export", "", 30) GUIDelete() To solve my problem i just remove the "FileOpen" like that: $sReportName = "C:\test\zNC\engine\Vinhos\VinhosTotal.rpt" That way it will not prompt me to select the file. Edited October 10, 2022 by alanbr00 Solution.
AutoBert Posted October 8, 2022 Posted October 8, 2022 1 hour ago, alanbr00 said: FileOpen would work for me, but i can't get it work in this script. I couldn't find any FileOpen,
alanbr00 Posted October 8, 2022 Author Posted October 8, 2022 9 minutes ago, AutoBert said: I couldn't find any FileOpen, It's because i wanna replace the FileOpenDialog with FileOpen:.I just edit my code.
Danp2 Posted October 8, 2022 Posted October 8, 2022 Why do you want to open the file in AutoIt? This doesn't make sense to me because you are trying to pass the file handle from AutoIt into the object's OpenReport method. Wouldn't you just pass the file's full path into the method? Latest Webdriver UDF Release Webdriver Wiki FAQs
alanbr00 Posted October 8, 2022 Author Posted October 8, 2022 (edited) 43 minutes ago, Danp2 said: Why do you want to open the file in AutoIt? This doesn't make sense to me because you are trying to pass the file handle from AutoIt into the object's OpenReport method. Wouldn't you just pass the file's full path into the method? What i'm trying to do is generating the report and export to PDF. That script it's doing exacly that, but i dont want need to select the file with the "FileOpenDialog", i have tried to use "FileOpen" intead, but with no success. Just solve my issue. Will add at beginning. Edited October 8, 2022 by alanbr00 Found the solution.
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now