0
votes

Hello my code is supposed to add another worksheet, then save the file and close it. my problem is with the save. It just doesnt save.

I did a

Do while (Not workbook.saved)
Workbook.save
Loop

And it went to a infinite loop -__- The workbook is a CSV file, being accessed via VBA. and returns 2 dialogue boxes which is turned off via

With Application
.DisplayAlerts = False
End With

Any ideas?

2
use ThisWorkbook instead of Workbook.ZAT
I know it's this workbook. I made an object and made it workbookLuigi
what alerts come up when .displayalerts is turned on?iliketocode
Guys I thank everyone for the help. I figured it out eventually after few hours of intensive debugging. It's actually saving and closing properly. It's just that it's doing it too fast the sheet that I added haven't been added and it's closing already. With this I end this question. Thanks.Luigi

2 Answers

1
votes

CSV file cannot contain multiple worksheets. Use SaveAs method instead of Save.

0
votes

instead of Workbook.save, you might want to use Workbook.Close True