Skip to Content
0

SAP VBA Scripting with multiple SAP Production Clients

Dec 11, 2017 at 07:20 PM

18

avatar image
Former Member

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

10 |10000 characters needed characters left characters exceeded
* Please Login or Register to Answer, Follow or Comment.

0 Answers