Closing Excel - no save prompt

S

Simon Woods

Hi

I'm automating Excel from VB, populating a sheet and then showing the user.
The user may or may not make chnages to this sheet. When the user closes
Excel, the user is not prompted to save changes, but rather Excel closes
down without asking. Is there a flag or something I can set to force Excel
to prompt for save changes if any changes have occurred to this sheet.

Thanks

Simon
 
J

Jim Rech

Excel should prompt to save. To test that I ran this script (copy and save
as a VBS file):

Dim XL
Set XL = CreateObject("Excel.Application")
XL.Workbooks.Add
XL.Activesheet.Range("A1").Value = "x"
XL.Visible = True

Quiting Excel without doing a thing I got a save prompt.

--
Jim
| Hi
|
| I'm automating Excel from VB, populating a sheet and then showing the
user.
| The user may or may not make chnages to this sheet. When the user closes
| Excel, the user is not prompted to save changes, but rather Excel closes
| down without asking. Is there a flag or something I can set to force Excel
| to prompt for save changes if any changes have occurred to this sheet.
|
| Thanks
|
| Simon
|
|
 
J

John Coleman

Simon said:
Hi

I'm automating Excel from VB, populating a sheet and then showing the user.
The user may or may not make chnages to this sheet. When the user closes
Excel, the user is not prompted to save changes, but rather Excel closes
down without asking. Is there a flag or something I can set to force Excel
to prompt for save changes if any changes have occurred to this sheet.

Thanks

Simon

Hi Simon,
My guess is that either your code (or maybe some other code in the
workbook you are opening) is setting Excel's display alerts property
equal to false. To test this, maybe include the fragment "msgbox
ExcelApp.DisplayAlerts" (if your application variable is ExcelApp) in
your script and see if it gives False. If so, including
ExcelApp.DisplayAlerts = True should fix the problem.

Hope that helps,

-John Coleman
 
S

Simon Woods

John Coleman said:
Hi Simon,
My guess is that either your code (or maybe some other code in the
workbook you are opening) is setting Excel's display alerts property
equal to false. To test this, maybe include the fragment "msgbox
ExcelApp.DisplayAlerts" (if your application variable is ExcelApp) in
your script and see if it gives False. If so, including
ExcelApp.DisplayAlerts = True should fix the problem.

Yep - you're right. I stopped alerts when populating the sheet and forgot to
switch it back on

Thanks

Simon
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top