VBA/Python - Translating a VBA code to Python code

Dear Experts,

I need to transfer a VBA Excel code to Python, simply having the following variables and they work fine in VBA:

Set SapGui = GetObject("SAPGUI")
Set Appl = SapGui.GetScriptingEngine
Set Connection = Appl.Children(0)
Set session = Connection.Children(0)
Set CollCon = Appl.Connections()

Open in new window


Regarding Python it works fine also till this point:

import win32com.client

SapGui = win32com.client.GetObject("SAPGUI")
print(SapGui)
Appl = SapGui.GetScriptingEngine
print(Appl)
Connection = Appl.Children(0)
print(Connection)
session = Connection.Children(0)

Open in new window


but being not sure in which format the CollCon variable should be in Python?

I tried this syntax:

CollCon = SapGui.GetScriptingEngine.Children([])

Open in new window


but that brings the following error message:

com_error: (-2147352567, 'Exception occurred.', (618, 'saplogon', 'Bad index type for collection access.', None, 0, 0), None)

Thanks in advance,
LVL 1
csehzIT consultantAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
I have never tried something similar but see if CollCon = SapGui.GetScriptingEngine.Children[0] works for you.
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
csehzIT consultantAuthor Commented:
Thanks that syntax at least works and being helpful
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
You're welcome!
BTW what's the point in awarding 750 points only?
0
Angular Fundamentals

Learn the fundamentals of Angular 2, a JavaScript framework for developing dynamic single page applications.

csehzIT consultantAuthor Commented:
Sorry for that 750 points, I do not really understand this new EE pointing system.

In the past there was a table that how many points should be assigned to the answer and that was clear. But now that disappeared and it can be seen just whether the help was "Helpful" or "Extremely helpful" and it seems the "Extremely helpful" is the 1000 points. Actually I selected "Helpful" and so that is probably 750.

Do you know is there any method to change the given points afterwards? I would give you 1000 with pleasure
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
I have never asked a question so don't know the procedure. But I think you can reassign the points, all you need is to look for various options on your end. As far as I know you get a slider which you can slide to award the points.
0
csehzIT consultantAuthor Commented:
Exactly that is the issue, that slider, which does not say for the person who asked the question, that which value on that slider means how many points.

Thanks for mentioning this for me, next time I will give always 'Extremely helpful' on that slider to add all the 1000 for the resolver
0
Subodh Tiwari (Neeraj)Excel & VBA ExpertCommented:
No worries!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
VBA

From novice to tech pro — start learning today.