on 12-08-2016 3:53 AM
when declaring vars in VBA such as:
Dim SAPGuiAuto As SAPFEWSELib.GuiApplication
Dim SAPConn As SAPFEWSELib.GuiConnection
Dim SAPSess As SAPFEWSELib.GuiSession
then setting them via
Set SAPGuiAuto = GetObject("SAPGUI")
or
set SAPSess = SAPConn.Sessions(0)
I get run time error '13': type mismatch
When using declarations such as
Dim SAPGuiAuto As Object
Dim SAPConn As Object
Dim SAPSess As Object
then all is well, except I lose the context of the available functions.
I've attempted a brute force approach by adding many references in excel
& trying all sorts of declarations.
any advice on specific declaration?
regards
Daniel
Hello Daniel,
as far as I can see are your declarations not correct, try this code:
Sub Test()
Dim SAPGuiAuto As Object
Dim SAPApp As SAPFEWSELib.GuiApplication
Dim SAPConn As SAPFEWSELib.GuiConnection
Dim SAPSess As SAPFEWSELib.GuiSession
Stop
Set SAPGuiAuto = GetObject("SAPGUI")
Set SAPApp = SAPGuiAuto.GetScriptingEngine
Set SAPConn = SAPApp.Children(0)
Set SAPSess = SAPConn.Children(0)
'...
End Sub
Let us know your results.
Cheers
Stefan
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks Stefan!
So simple, much appreciated 🙂
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
User | Count |
---|---|
85 | |
10 | |
10 | |
9 | |
7 | |
7 | |
6 | |
5 | |
4 | |
4 |
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.