ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Macro to close without saving (https://www.excelbanter.com/excel-programming/410296-macro-close-without-saving.html)

Leanne M (Aussie)

Macro to close without saving
 
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


--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)

Gary''s Student

Macro to close without saving
 
Sub close_out()
ActiveWorkbook.Saved = True
ActiveWorkbook.Close
End Sub

--
Gary''s Student - gsnu200782


"Leanne M (Aussie)" wrote:

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


--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)


donwb

Macro to close without saving
 
Try Workbooks("MyBook1.xls").Close SaveChanges:=False
where MyBook.xls is your workbook
donwb

"Leanne M (Aussie)" wrote in
message ...
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


--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)




Mike H

Macro to close without saving
 
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

"Leanne M (Aussie)" wrote:

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


--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)


Leanne M (Aussie)

Macro to close without saving
 
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.
--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)


"Mike H" wrote:

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

"Leanne M (Aussie)" wrote:

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


--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)


Leanne M (Aussie)

Macro to close without saving
 
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!
--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)


"Gary''s Student" wrote:

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

--
Gary''s Student - gsnu200782


"Leanne M (Aussie)" wrote:

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


--
Leanne M (Aussie)
(Changed Display name from Leanne)
United Kingdom
(Don''t ask me what an Aussie is doing living in the UK!)



All times are GMT +1. The time now is 10:07 AM.

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