How to save document with different name, if certain row contains a special character? How to save document with different name, if certain row contains a special character? tkinter tkinter

How to save document with different name, if certain row contains a special character?


You had it so close! add .text end of your cells[2].

This is what it should look like:

 if "*" in cells[2].text:     print("true")     document.save("Failed.docx") else:     document.save("test.docx")


I may not be understanding the question. Are you asking how to change the document name, or how to properly check for the "*" character?

Changing the name is simple; just use a variable.

docname = "test.docx"for idx, item in enumerate(vars):    cells = table.add_row().cells    cells[0].text = info[idx]  # gets the option name    val = item.get()  #radiobutton value    if val == 2:  # checks if yes        cells[1].text = "*"    elif val == 1:   # checks if no        cells[2].text = "*"        docname = "failed.docx"    elif val == 0:   # checks if N/A        cells[3].text = "*"        docname = "failed.docx"document.save(docname)