VBA not closing *.xlsx file

Cummins

Board Regular
Joined
Jul 26, 2011
Messages
58
My code opens, creates and then closes a file when the information has been collected. The following line has always worked before. The only change is that the default file type is now *.xlsx.

Workbooks(TempBookName).Close SaveChanges:=False

Is the command different in 2010?
 

Excel Facts

Can Excel fill bagel flavors?
You can teach Excel a new custom list. Type the list in cells, File, Options, Advanced, Edit Custom Lists, Import, OK
It should close your workbook, without saving it. I'm assuming that TempBookName is a variable holding the name of the workbook that you'd like close, correct? What value has it been assigned? Also, when you say that it doesn't work, what happens exactly?
 
Upvote 0
Yes, TempBookName is a variable. It literally creates a temporary file....Book31.xls (or Book31.xlsx), Book32.xls (or Book32.xlsx)....
Every time the vba program reaches the line to close the file, the pop up screen opens asking if I want to save the file....
I tried something and here is the issue. This only started when I saved the VBA program as *.xlsm instead of *.xls. Obviously, something changed....
 
Upvote 0

Forum statistics

Threads
1,223,903
Messages
6,175,284
Members
452,630
Latest member
OdubiYouth

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top