Skip to content

unable to delete pictures with duplicated name #2697

@ytyk668

Description

@ytyk668

Assume there are 3 pictures with the same name. Using picture.delete(), the first/last is successfully deleted, when the program runs the second time in the loop, delete of picture fails.

Please clarify whether this behaviour is expected, if yes, it is suggested to show in the error message. It was quite confusing when receiving the error.

Same behaviour is observed with renaming using picture.name="new name". It is suspected that the object reference failed.

Code to reproduce error:

wb = xlwings.Book(path)
for sht in list(wb.sheets):
  for picture in list(sht.pictures):
    picture.delete()

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions