2017 Dec 11 7:20 PM
I'm trying to write a script that in one script will look for one client (SID) and in another it will look for the other client (SID)
When I use this one, I get a "compile error"
Function Getorders()
Dim SapGuiAuto As Object
Dim Application As SAPFEWSELib.GuiApplication
Dim Connection As SAPFEWSELib.GuiConnection
Dim i As Integer
Dim Conn As String
Dim Flag As Boolean
Flag = False
Set SapGuiAuto = GetObject("SAPGUI")
Set Application = SapGuiAuto.GetScriptingEngine
If Application.Connections.Count() > 0 Then
For i = 0 To Application.Connections.Count() - 1
Set Connection = Application.Children(i)
Conn = Connection.Description()
If Conn = "Cessna1. SAP ECC Production" Then
Flag = True
Exit For
End If
Next
If Flag = False Then
Set Connection = Application.OpenConnection("Cessna1. SAP ECC Production")
End If
'Insert your code here
Set Connection = Nothing
Else
Set Connection = Application.OpenConnection("Cessna1. SAP ECC Production")
'Insert your code here
Set Connection = Nothing
End If
End Function