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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

VBA and pass through SanScript 1

Status
Not open for further replies.

Magic427

IS-IT--Management
Apr 10, 2003
6
GB
Here is the problem. We use Crystal Integration/Dynamics Report Manager from Rockton.

I have one report I must run from VBA as it's use depends on details held against the customer.

Previously I got the code to work in VBA by use of the following extract:
QUOTE = Chr(34)

Set DynamicsApp = CreateObject("Dynamics.Application")

DynamicsApp.CurrentProduct = "eEnterprise"

DynamicsApp.Activate



' Old CI calls below

i = DynamicsApp.executesanscript("call with name " & QUOTE & "Initialize_Parameters" & QUOTE & " in dictionary 2233," & QUOTE & "ORDERCONF" & QUOTE & ",errnum", Error)

i = DynamicsApp.executesanscript("call with name " & QUOTE & "Print_Crystal_Report" & QUOTE & " in dictionary 2233," & QUOTE & "ORDERCONF" & QUOTE & ",false,false,false,false,false,1,0," & QUOTE & "" & QUOTE & ".", Error)

However, we are now on DRM and all the calls are different.
I have tried to make it work, but I think the problem is that I can't retrieve the ReportInstance that is created by the call, and thus the rest of it, won't work. Mark @ Rockton doesn't have any experience of VB, and to be honest I had to work out the use of their API on my own last time. The API file on their site details the syntax but does not have any vb examples

Attempted code:
i = DynamicsApp.executesanscript("call with name " & QUOTE & "Integration_Initialize_Report" & QUOTE & " in dictionary 5014," & QUOTE & "ORDERCONF" & QUOTE & ",reportinstance, errnum", Error)

i = DynamicsApp.executesanscript("call with name " & QUOTE & "Integration_Parameter_Values_Clear" & QUOTE & " in dictionary 5014," & reportinstance & ",1", Error)

i = DynamicsApp.executesanscript("call with name " & QUOTE & "Integration_Parameter_Values_Set" & QUOTE & " in dictionary 5014," & reportinstance & ",1,1,1," & QUOTE & "ORD157579" & QUOTE, Error)

Please Please Please help me!

Neil
 
Hi Neil,
After installing 9.0.12 of DRM, here is how I got the code to work

Code:
Public Sub drmcall()


Dim dynamicsapp As Object
Dim QUOTE As String
Dim strSanScript As String


QUOTE = Chr(34)

Set dynamicsapp = CreateObject("Dynamics.Application")
dynamicsapp.CurrentProduct = "eEnterprise"
dynamicsapp.Activate

strSanScript = "local integer reportinstance ; "
strSanScript = strSanScript + vbCrLf + "local integer returnErrNum ; "
strSanScript = strSanScript + vbCrLf + ""
strSanScript = strSanScript + vbCrLf + "call with name " & QUOTE & "Integration_Initialize_Report" & QUOTE & " in dictionary 5014," & QUOTE & "SALESINVHISTENQ" & QUOTE & ",reportinstance, returnErrNum ;"
strSanScript = strSanScript + vbCrLf + "if returnErrNum <> 0 then"
strSanScript = strSanScript + vbCrLf + "  warning (  " & QUOTE & "error initiating DRM " & QUOTE & " ) ; "
strSanScript = strSanScript + vbCrLf + "else "
strSanScript = strSanScript + vbCrLf + "call with name " & QUOTE & "Integration_Parameter_Values_Clear" & QUOTE & " in dictionary 5014,reportinstance ,1 ;"
strSanScript = strSanScript + vbCrLf + "call with name " & QUOTE & "Integration_Parameter_Value_Set" & QUOTE & " in dictionary 5014,reportinstance,1,1," & QUOTE & "INVPC0071" & QUOTE & ", " & QUOTE & QUOTE & " ; "
strSanScript = strSanScript + vbCrLf + "call with name " & QUOTE & "Integration_Launch_Report" & QUOTE & " in dictionary 5014, reportinstance, returnErrNum ;"
strSanScript = strSanScript + vbCrLf + "end if ;"

retVal = MsgBox("About to execute the following sanscript " & vbCrLf & vbCrLf & strSanScript)
retVal = InputBox("Code", "Code", strSanScript)

i = dynamicsapp.executesanscript(strSanScript, Error)
If i <> 0 Then
    MsgBox ("Error in the sanscript code : " & i & vbCrLf & Error)
End If



End Sub

Trust this helps

Robert
 
Thanks Robert

Seems to work a treat.

I just now need to sort out why DRM doesn't send embedded addresses to Zetafax in these versions and it will all be sorted.

Neil
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top