Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable or auto-answer Do you want to save the changes in “workbook” 1

Status
Not open for further replies.

Eseke

Technical User
Jan 23, 2007
9
NL
I wanted to know if it was possible to automatically answer the message box “Do you want to save the changes in “workbook”” with NO.
This is because I already have a macro that saves the sheet under a unique name. And after saving resets the entire sheet so when I’m done I can start without any trouble and reuse the macro to safe and reset.
So when I’m finally done I don’t want to save.
 
Presumably your trying to close an Excel workbook if your getting this message, in which case try using:

Code:
Workbooks("YourWorkbookName").Close (False)
 
add this line in your macro:

Workbooks("Workbookname.xls").Close Savechanges:=False

Member- AAAA Association Against Acronym Abusers
 
I will try it.

Thanks for the quick response.
 
It didn’t work but that will come because of a part of the macro that I use to name my saved workbook.

The macro that I use is as followed:
ChDir "C:\ resultaten\ "
ActiveWorkbook.SaveAs Filename:= _
"C:\ resultaten\resultaten" & Format$(Now, "YYMMDD_HHMMSS") & ".xls", FileFormat _
:=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
False, CreateBackup:=False

Each time that I use the macro will result in a unique name and that is part of the purpose of the macro.

Is it still possible to use this code and still close the opened workbook.

 
As you are saving the workbook with a name down to the second, I would apply the time to a variable and then use that to save and close the workbook.

Code:
tim$ = format(now, "yymmdd_hhmmss")
ActiveWorkbook.SaveAs Filename:= _
        "C:\ resultaten\resultaten" & tim$ & ".xls", FileFormat _
        :=xlNormal, Password:="", WriteResPassword:="", ReadOnlyRecommended:= _
        False, CreateBackup:=False

workbooks(resultaten" & tim$ & ".xls").close (false)
 
Thanks Molby it helped me for the most part.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top