question

Abel van der Windt avatar image
1 Like"
Abel van der Windt asked Abel van der Windt commented

Bug exceldeletesheet?

Hi,

I am trying to delete the content of Excel sheets I later want to fill with data. See the script window for the code. However, I get an error message that FlexSim is unable to delete Sheet1.

Is this a bug or am I using it the wrong way?

Regards,

Abel

exceldeletesheet.fsm

Test.xlsx

FlexSim 21.0.4
flexsim 21.0.4exceldeletesheet
test.xlsx (7.7 KiB)
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

1 Answer

Ben Wilson avatar image
1 Like"
Ben Wilson answered Abel van der Windt commented

Hi @Abel van der Windt,

Excel's interface is not displayed for user interaction, but you are using the optional 2nd parameter of exceldeletesheet() which requires the user to confirm the action. Because Excel's interface is not available, you can't confirm, and things freeze up. Here is what is going on in Windows Task Manager:

Even though you can't see Excel, it is waiting for your input, and so nothing happens.

Try removing the optional 2nd parameter from your call to exceldeletesheet(), or try explicitly setting it to 0.

Also, I did see the same error you mentioned the first time I tried your code ("FlexSim is unable to delete Sheet1"). However, after dismissing the error, I started Excel via double-clicking the test.xlsx file. Then after closing Excel (and making sure there were no remaining Excel processes listed in Task Manager) then your code seems to work properly (minus the optional 2nd param discussed above), and I haven't been able to duplicate the problem since.

Let us know what you find.


1618370130962.png (4.5 KiB)
· 1
5 |100000

Up to 12 attachments (including images) can be used with a maximum of 23.8 MiB each and 47.7 MiB total.

Abel van der Windt avatar image Abel van der Windt commented ·

Thanks for the explanation!

0 Likes 0 ·