R rodmcm Active Member Licensed User Longtime User Feb 11, 2021 #1 My program creates a work book and allows the user multiple data saves, each set of data to a new sheet The problem is how to call wb.Save(Dir,Filename). I can't call it after each sheet is populated as I get an error 'Stream Closed" for any subsequent save I can put a button called Save on the screen to do this, but the problem is that I cannot control when the user will hit it. It could be after he saves sheet 0, so evoking an error on his next sheet save, or the user could quit the program ( top right cross) at any time so loosing all his data. I need a way to finally save the workbook when he quits I tried saving the workbook after each sheet save and reopening at each subsequent sheet save. This also gives the error Any ideas to get around this? B4X: Copy Sub OpenExistWorkbook Log("Open Existing Workbook") If wb.IsInitialized = False Then wb.InitializeExisting(Folder, WorkBookName,"") End If End Sub
My program creates a work book and allows the user multiple data saves, each set of data to a new sheet The problem is how to call wb.Save(Dir,Filename). I can't call it after each sheet is populated as I get an error 'Stream Closed" for any subsequent save I can put a button called Save on the screen to do this, but the problem is that I cannot control when the user will hit it. It could be after he saves sheet 0, so evoking an error on his next sheet save, or the user could quit the program ( top right cross) at any time so loosing all his data. I need a way to finally save the workbook when he quits I tried saving the workbook after each sheet save and reopening at each subsequent sheet save. This also gives the error Any ideas to get around this? B4X: Copy Sub OpenExistWorkbook Log("Open Existing Workbook") If wb.IsInitialized = False Then wb.InitializeExisting(Folder, WorkBookName,"") End If End Sub
Erel B4X founder Staff member Licensed User Longtime User Feb 11, 2021 #2 Not sure if it is the best solution but you can save it in the MainForm_Closed event. Upvote 0