Results 1 to 3 of 3

Thread: Pyhton Script Called by xlwings Addin

  1. #1
    VBAX Newbie
    Oct 2017

    Pyhton Script Called by xlwings Addin

    I am attempting to use a basic example of xlwings. I have the following VBA script:

    Sub Test()
            RunPython ("import VBAtester; VBAtester.test()")
            MsgBox ("Script has run.")
        End Sub

    Which is in the same directory as the python script

    import xlwings as xw
    def test():
    wb = xw.Book.caller()
    wb.sheets[0].range('A1').value = 'TEST VALUE'

    The VBA script runs and outputs the message box; but *'TEST VALUE'* does not show in cell A1, or elsewhere. I know the python script is being called as if I purposefully put errors in my python script VBA will callback these errors when I run the VBA script that calls the python script.

    What is the error in my understanding or my approach?

    Moderator Edit:
    Last edited by SamT; 10-29-2017 at 05:47 PM. Reason: Formatted Code

  2. #2

  3. #3
    Moderator VBAX Wizard SamT's Avatar
    Oct 2006
    Near Columbia
    VBA doesn't do scripts. VBA does source code. It compiles.
    vbs does scripts

    As far as your python script, I don't know if anybody here uses Python. Wait and see


    Might need to read

    Even better would be to pass the Name of the Worksheet, the numerical index depends on it's tab position.

    Also, I am clueless if 'A1' will reach the Excel Workbook as "A1". The lack of capitalization of the Collections will probable by OK.

    What is the error in my understanding or my approach?
    Hard to say... You haven't given us your entire "approach."
    Last edited by SamT; 10-29-2017 at 05:39 PM.
    I expect the student to do their homework and find all the errrors I leeve in.

    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts