Quantcast
Channel: Sage 100
Viewing all articles
Browse latest Browse all 36990

Forum Post: Script to launch Crystal report from button, Sage 100 Premium

$
0
0
  I have a script I found probably on Sage City that will pass parameters from the screen (ie customer number from AR customer maintenance) and launches a custom Crystal report.   I have successfully used this on MAS90/200 providex.   I am trying to apply this same script to another client, running Sage 100 Premium(SQL) and the script errors out on the creation of the object.  Is the syntax different for SQL or is there something missing on the workstation?  I thought the latter was the case when I first attempted to run this on their server.  The workstation client has not been run the server so I presumed that was the reason for the error.  I then attempted it on another machine with the client software installed and get the same error.   Thanks!   Error is: OLE Error Number: 429  Active X component can't create object: 'CrystalRuntime.Applicaton'   'Script to print Open Invoice batches report using customer number from screen ' ' Dim App, RptFile, RptWindow, User, Comp, Pw, Dest, RptSelect Dim Rept, Login, ExportFile, ParamFields, strYear, objShell ' '********************************************************* 'Report File: Change to the full path and file name strFile = "SO_AllBatches_Custom.rpt" strRptFile = " \\server\Acct\CustomReports " + strFile strPath = " \\server\acct\CustomReports\ " strExportFile = strPath + "SO_AllBatches_Custom.rpt" 'Login User = "SA" : Comp = "ABC" : PW = "" ' User = MAS_SCR_USR : Comp = MAS_SCR_CMP : PW = "" 'Future version should use connection string Set objShell = CreateObject("WScript.Shell") RegLocate = "HKEY_CURRENT_USER\SOFTWARE\ODBC\ODBC.INI\SOTAMAS90\" objShell.RegWrite RegLocate & "UID",User objShell.RegWrite RegLocate & "PWD",PW objShell.RegWrite RegLocate & "COMPANY",Comp 'Destination Export, Print or Preview - set it to 2 to Export, 1 to Print and 0 to Preview Dest = 0 ' ' Report Selection 'RptSelect = "{SO_SalesOrderHeader.SalesOrderNo} = " & CHR(34) & 'SO_SalesOrder_bus_SalesOrderNo & CHR(34)  RptSelect ="{SO_InvoiceHeader.CustomerNo} = " + CHR(34) + AR_Customer_bus_CustomerNo +CHR(34) '********************************************************** Set oApp = CreateObject ("CrystalRuntime.Application") 'CRAXDRT.dll - older one is CRPE32.dll Set oRpt = oApp.OpenReport (strRptFile) Login = oApp.LogonServer("p2sodbc.dll","SOTAMAS90") ' ' Export Options With oRpt  .DisplayProgressDialog = False ' True  .MorePrintEngineErrorMessages = False 'True  .EnableParameterPrompting = False 'True  .DiscardSavedData    'Exporting Starts Here  'Helpful URLs for exporting options (some info only applies to older Crystal versions but VERY resourceful)  ' http://tinyurl.com/3jvl2tl  ' http://tinyurl.com/3sj7qqh  ' http://tinyurl.com/3fdpcqx    .ExportOptions.DiskFileName = strExportFile  .ExportOptions.DestinationType = 1 '1= filesystem  .ExportOptions.FormatType = 31  '31= PDF  .ExportOptions.PDFExportAllPages = True  ' .Export(False) End With    If Not(IsNull(RptSelect)) Then  oRpt.RecordSelectionFormula = RptSelect End if ' ' 'Set ParamFields = oRpt.ParameterFields 'Set oState = ParamFields.Item(1) 'oState.SetCurrentValue "IL",12 ' If Dest = 2 Then  oRpt.Export(False) End If if Dest =1 then         oRpt.Printout(False) End If Set WshShell = CreateObject("WScript.Shell") ' Display PDF 'WshShell.CurrentDirectory = strPath ' MsgBox "strExportFile = " + strExportFile 'WshShell.Run CHR(34) + strExportFile + CHR(34) ' While WshShell.AppActivate(RptWindow) = TRUE ' Wscript.sleep 2500 ' Wend ' Set WshShell=Nothing Set Rept=Nothing Set App=Nothing '  MsgBox "Report Printed" ' script end '

Viewing all articles
Browse latest Browse all 36990

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>