Opening .XLS So It Does Not Prompt For "Save Changes"?

P

PeteCresswell

My best shot so far:

myExcelApp.Workbooks.Open Filename:=theSsPath, UpdateLinks:=False,
ReadOnly:=False


Doesn't seem tb enough. If/when my code abends later on - with the
workbook open - Excel issues the dreaded "Do you want to save changes"
prompt.

Granted the code shouldn't abend.....

But in the meanwhile, is there anything I can do to suppress that "Do
you want to save changes..." prompt?
 
D

Dennis

Try

Application.DisplayAlerts = False
....
Your code in here
....
Application.DisplayAlerts = True
 
P

PeteCresswell

Sorry, Forget my post I have answered for Excel programming.

Even if turning off DisplayAlerts would work from MS Access too....
the problem is that I would have to turn it off more-or-less globally
and I didn't want to do that.

Was hoping for some additional parm to specify when opening
the .XLS. Doesn't seem logical that if I open it "ReadOnly", there
could be changes to save in the first place...... so maybe I'm doing
something wrong when I'm opening it.
 
C

Clif McIrvin

PeteCresswell said:
My best shot so far:

myExcelApp.Workbooks.Open Filename:=theSsPath, UpdateLinks:=False,
ReadOnly:=False


Doesn't seem tb enough. If/when my code abends later on - with the
workbook open - Excel issues the dreaded "Do you want to save changes"
prompt.

Granted the code shouldn't abend.....

But in the meanwhile, is there anything I can do to suppress that "Do
you want to save changes..." prompt?


No, I don't. Your question seemed relevant to work I may be doing, so I
did a quick scan of excel.application and workbook properties and came
up with two possibilities -- neither of which actually save any pending
changes:

-------
Example
This example closes the workbook Book1.xls and doesn't prompt the user
to save changes. Any changes to Book1.xls aren't saved.

Application.DisplayAlerts = False
Workbooks("BOOK1.XLS").Close
Application.DisplayAlerts = True
------------

It looks like you could set DisplayAlerts to False when
you open and True when you close - In the event of an abend you may have
some cleanup work to do inside the excel application.

The second possibility looks cleaner to me, but would require you to add
"ThisWorkbook.Saved = True" to your code everywhere you modify the
workbook -- which of course may not be desirable in the long run <g>

-----------------
This example closes the workbook that contains the example code and
discards any changes to the workbook by setting the Saved property to
True.

ThisWorkbook.Saved = True
ThisWorkbook.Close
-----------
 
C

Clif McIrvin

Dennis said:
Sorry, Forget my post I have answered for Excel programming.

Actually, Dennis, changing your suggestions to:
Try

myExcelApp.DisplayAlerts = False
....
Your code in here
....
myExcelApp.DisplayAlerts = True

would set the DisplayAlerts property for the Excel Application; I didn't
suggest it because I didn't think it would solve Pete's issue
(untested.)

And Pete, if you posted a copy and paste, you're setting ReadOnly to
FALSE, not TRUE .... that'd be the first thing I'd check.
 
P

PeteCresswell

Duhhhhhhhhh ! -)

Maybe it's time for Plan C: Go home, get into bed, assume the foetal
postion, and turn the electric blanket up to 9.....
 
C

Clif McIrvin

PeteCresswell said:
Duhhhhhhhhh ! -)

Maybe it's time for Plan C: Go home, get into bed, assume the foetal
postion, and turn the electric blanket up to 9.....


<G> Afraid I've been there before myself.

LOL
 

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