Menu

Using Python Objects in VBA

John R.
2015-04-29
2015-04-29
  • John R.

    John R. - 2015-04-29

    All,

    First, let me say that I cannot express how helpful this library is. It has saved me a world of trouble in re-writing a number of python libraries that we have for excel in VBA, many of which use python libraries developed by others, which would be a nightmare.

    I am using ExcelPython to return a python dictionary of objects that I have built. I can access the individual items in the dictionary using py.getitem and I can store them in a Variant or Object variable in VBA. I was wondering if there was a way to access the data members of those objects.

    If all else fails, I can write the str function of those objects to return the data in a dictionary-like format, which I probably should do anyway if I'm being a good python developer, use Py.Str(myObject) and parse the data from there.

    Thanks in advance!
    John

     
  • Eric Reynolds

    Eric Reynolds - 2015-04-29

    Hi John,

    Thanks very much for your appreciative comments!

    So you should be able to use Py.GetAttr(myObject, "attribute_name") to retrieve data members. FYI, to find out about the Py. functions you have at your disposal to manipulate Python objects from VBA just take a look at the source code here.

    Hope this helps,

    Best regards,

    Eric.

     

Log in to post a comment.