Macro to close without saving

  • Thread starter Leanne M (Aussie)
  • Start date
L

Leanne M (Aussie)

Hi,

I have a file which is to be viewed only.

I have got the code to close the workbook but I want to include the fact
that it should be closed without saving changes.

Is this possible?

My code for closing is simply

ActiveWorkbook.Close

Thanks
 
G

Gary''s Student

Sub close_out()
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
End Sub
 
D

donwb

Try Workbooks("MyBook1.xls").Close SaveChanges:=False
where MyBook.xls is your workbook
donwb
 
M

Mike H

Hi,

There are seveal macro based ways but if the user doesn't enable macros then
you have a problem. Why not simply set the file as read only by right click
in Windows explorer, select properties and set it as read only.

This can still be defeated but is probably as secure as any macro based
solution.

Mike
 
L

Leanne M (Aussie)

Hi Mike,

As the whole file is Macro dependant nothing will work if they do not enable
macros. You have a good point about making it read only though.
 
L

Leanne M (Aussie)

Hi,

I have tried both suggested macro codes and neither of them work.

When I go back into view the code I get the following error message??

'Object Library invalid or contains references to object definitions that
could not be found'

I don't think this has caused it but I have never had this before - VB help
is of no help at all!
 

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