ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Problem closing a workbook using a macro (https://www.excelbanter.com/excel-programming/310705-problem-closing-workbook-using-macro.html)

steve

Problem closing a workbook using a macro
 
The last part of my macro is a save command:

ActiveWorkbook.SaveAs
Filename:="H:\Personal\SIGINCUSTODY.csv", FileFormat _
:=xlCSV, CreateBackup:=False

The file is saved to its required location in csv format.

I then have a command that says ActiveWorkbook.Close,
however, this command will not work automatically. First
of all I get asked the question "Do you want to save the
changes you made to SIGINCUSTODY". After pressing Yes it
asks me to select the location where the file should be
saved. I select the file name as above (to where the file
has already been saved). I then asked do I want to
overwrite the file (as i have already saved it earlier in
the macro) and finally I get asked am I sure that I want
to save in csv format.

Is there anyway of just closing the file without being
asked all these questions ?

Thanks
Steve

Jan Karel Pieterse

Problem closing a workbook using a macro
 
Hi Steve,

Is there anyway of just closing the file without being
asked all these questions ?


Su

ActiveWorkbook.Close SaveChanges:=False

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com


Nikos Yannacopoulos[_5_]

Problem closing a workbook using a macro
 
Steve,

ActiveWorkbook.Close False

will close the workbook without prompting to save - and without saving, but
since you've only just saved, that should be OK.

HTH,
Nikos

"Steve" wrote in message
...
The last part of my macro is a save command:

ActiveWorkbook.SaveAs
Filename:="H:\Personal\SIGINCUSTODY.csv", FileFormat _
:=xlCSV, CreateBackup:=False

The file is saved to its required location in csv format.

I then have a command that says ActiveWorkbook.Close,
however, this command will not work automatically. First
of all I get asked the question "Do you want to save the
changes you made to SIGINCUSTODY". After pressing Yes it
asks me to select the location where the file should be
saved. I select the file name as above (to where the file
has already been saved). I then asked do I want to
overwrite the file (as i have already saved it earlier in
the macro) and finally I get asked am I sure that I want
to save in csv format.

Is there anyway of just closing the file without being
asked all these questions ?

Thanks
Steve




steve

Problem closing a workbook using a macro
 
Thanks Nikos and Jan
-----Original Message-----
Hi Steve,

Is there anyway of just closing the file without being
asked all these questions ?


Su

ActiveWorkbook.Close SaveChanges:=False

Regards,

Jan Karel Pieterse
Excel MVP
www.jkp-ads.com

.



All times are GMT +1. The time now is 11:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com