Uncategorized

Is it possible to acces value in TextBox in UserForm(Excel) from python?


I would like to ask you if it is possible to use value form TextBox in UseForm Excel from python using xlwings. For examle i would like to make function in python to make something with the values that are in the TextBoxes.

I tried something like this:

wb = xw.Book.caller()
sheet = wb.sheets[0]
value_from_textbox = sheet.shapes['TextBox1'].text_frame2.text_range.text
sheet["A1"].value = value_from_textbox 

or this:

def on_click():
    wb = xw.Book.caller()
    useform = wb.sheets["UseForm1"]
    textbox1 = useform.controls["Textbox1"]
    text = textbox1.value
    wb.sheets["Sheet1"].range("A1").value = text

And i always got an error in excel.



Source link

Leave a Reply

Your email address will not be published. Required fields are marked *