Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default how do I prevent a workbook from being saved?

At a certain point in my macro, the User can make a decision to create a new
workbook (called "Investment Quotation" as shown below). A small portion of
the macro is shown, below. At that point, the macro performs a
copy-and-paste from the current workbook to a new workbook. When that
happens, I need to prevent the original (first) workbook from being saved. (I
won't know the name of the first workbook.)

The problem is that I want the User to have the right to save/change the
original workbook. It's just that I'm trying to prevent them from saving the
original workbook ONLY if they decide to create a new workbook.

So, I guess my question is: how do I tell Excel to "don't allow a save" to
the first workbook? (Again, the User is allowed to save the file BEFORE
this part of the macro is executed.)

Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Investment Quotation"
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 441
Default how do I prevent a workbook from being saved?

One way I think would work:

After the paste is done add the following code lines:

ThisWorkbook.Activate
ThisWorkbook.Close SaveChanges:=False

This would cause the "Original" to be destroyed, thus solving your dilemma.
You could put a warning message for the user warning them that once they
elect to create a new book, the "Original" will no longer be available...

HTH.

"crimsonkng" wrote:

At a certain point in my macro, the User can make a decision to create a new
workbook (called "Investment Quotation" as shown below). A small portion of
the macro is shown, below. At that point, the macro performs a
copy-and-paste from the current workbook to a new workbook. When that
happens, I need to prevent the original (first) workbook from being saved. (I
won't know the name of the first workbook.)

The problem is that I want the User to have the right to save/change the
original workbook. It's just that I'm trying to prevent them from saving the
original workbook ONLY if they decide to create a new workbook.

So, I guess my question is: how do I tell Excel to "don't allow a save" to
the first workbook? (Again, the User is allowed to save the file BEFORE
this part of the macro is executed.)

Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Investment Quotation"

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 694
Default how do I prevent a workbook from being saved?

Hi,
not sure i get it completely, but if you want the users to save a copy of
the current state of an open book, you can do a SaveCopyAs:
- say book1.xls is the currently open book
- do a SaveCopyAs into book2.xls
- book1 is still open in the current state (not saved yet) and a copy of the
current state has been saved to the closed book book2.xls
Would that work for you?

'--------------------------------------------------
Sub SaveACopy()
Dim wkb As Workbook
Dim f As Variant

Set wkb = ActiveWorkbook '<------- Active Book

'ask user to save a Copy
f = Application.GetSaveAsFilename("New Book.xls", "Excel File (*.xls),
*.xls", , "Save a Copy")
If f < "False" Then 'user did not click Cancel button -- save copy
wkb.SaveCopyAs f
Else
MsgBox "SaveCopy cancelled by user."
End If

End Sub
'---------------------------------------
--
Regards,
Sébastien
<http://www.ondemandanalysis.com


"crimsonkng" wrote:

At a certain point in my macro, the User can make a decision to create a new
workbook (called "Investment Quotation" as shown below). A small portion of
the macro is shown, below. At that point, the macro performs a
copy-and-paste from the current workbook to a new workbook. When that
happens, I need to prevent the original (first) workbook from being saved. (I
won't know the name of the first workbook.)

The problem is that I want the User to have the right to save/change the
original workbook. It's just that I'm trying to prevent them from saving the
original workbook ONLY if they decide to create a new workbook.

So, I guess my question is: how do I tell Excel to "don't allow a save" to
the first workbook? (Again, the User is allowed to save the file BEFORE
this part of the macro is executed.)

Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Investment Quotation"

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default how do I prevent a workbook from being saved?

Maybe you could set its Saved property to true, and close it


Set this = ActiveWorkbook
Cells.Copy
Workbooks.Add
ActiveSheet.Paste
Sheets("Sheet1").Name = "Investment Quotation"
this.Saved = True
this.Close

--

HTH

RP
(remove nothere from the email address if mailing direct)


"crimsonkng" wrote in message
...
At a certain point in my macro, the User can make a decision to create a

new
workbook (called "Investment Quotation" as shown below). A small portion

of
the macro is shown, below. At that point, the macro performs a
copy-and-paste from the current workbook to a new workbook. When that
happens, I need to prevent the original (first) workbook from being saved.

(I
won't know the name of the first workbook.)

The problem is that I want the User to have the right to save/change the
original workbook. It's just that I'm trying to prevent them from saving

the
original workbook ONLY if they decide to create a new workbook.

So, I guess my question is: how do I tell Excel to "don't allow a save" to
the first workbook? (Again, the User is allowed to save the file BEFORE
this part of the macro is executed.)

Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Investment Quotation"



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 42
Default how do I prevent a workbook from being saved?

Thanks, everyone, for the suggestions. I'll try 'em all but it sounds like
Quartz's is what I want. Thanks, again.
Dan

"crimsonkng" wrote:

At a certain point in my macro, the User can make a decision to create a new
workbook (called "Investment Quotation" as shown below). A small portion of
the macro is shown, below. At that point, the macro performs a
copy-and-paste from the current workbook to a new workbook. When that
happens, I need to prevent the original (first) workbook from being saved. (I
won't know the name of the first workbook.)

The problem is that I want the User to have the right to save/change the
original workbook. It's just that I'm trying to prevent them from saving the
original workbook ONLY if they decide to create a new workbook.

So, I guess my question is: how do I tell Excel to "don't allow a save" to
the first workbook? (Again, the User is allowed to save the file BEFORE
this part of the macro is executed.)

Cells.Select
Selection.Copy
Workbooks.Add
ActiveSheet.Paste
Sheets("Sheet1").Select
Sheets("Sheet1").Name = "Investment Quotation"

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
How can I prevent file from being saved or printed in Excel? ProfReggie Setting up and Configuration of Excel 1 May 4th 09 11:43 PM
Prevent data from typing in another cell in a saved template? Puzzlesolver Excel Worksheet Functions 3 August 26th 08 04:37 PM
How do I prevent Hyperlinks from changing when saved? Doug Excel Discussion (Misc queries) 0 March 13th 06 01:15 AM
How do I prevent someone from deleting a workbook? JSP Excel Discussion (Misc queries) 5 September 5th 05 04:51 PM
How can I see a copy of a saved workbook before I saved it again? Norma Excel Worksheet Functions 2 May 11th 05 10:31 AM


All times are GMT +1. The time now is 12:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"