ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Why does Excel ask me to save changes? (https://www.excelbanter.com/excel-programming/355116-why-does-excel-ask-me-save-changes.html)

Ebbe[_2_]

Why does Excel ask me to save changes?
 
Hi

I have a little workbook with two sheets.
On the sheet in the front (named Start) I have placed a ListBox (named
lstTemplates, ListFillRange:Tabel!A:A) and a CommandBottom (named cmdSelect)
and a CommandBottom (named cmdCancel).
On the sheet in the background (named Table) I have the data used to fill in
the listbox and the macros below.

If I open the workbook and immediately clicks on cmdCancel, the Excel asks
me if I want to save changes.
To avoid this question I have to uncomment the "ActiveWorkbook.Save".

Why is it necessary to save? I haven't changed anything!
Is there a way to avoid the "'ActiveWorkbook.Save" before the
"Application.Quit"?
I have tried with a "ActiveWorkbook.Close SaveChanges = False", but the
"Application.Quit" didn't execute.
The .xls file will be placed in a writeprotected area, therefor the
"ActiveWorkbook.Save" will be a bad idear to use.

Macroes related to sheet "Start" ------------------------------------ begin
Private Sub cmdCancel_Click()
If Workbooks.Count 1 Then
ActiveWorkbook.Close SaveChanges = False
Else
'ActiveWorkbook.Save
Application.Quit
End If
End Sub

Private Sub cmdSelect_Click()
OpenTemplate
End Sub

Private Sub lstTemplates_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
OpenTemplate
End Sub

Private Sub OpenTemplate()
Dim WorkbookName As String
Dim i As Integer
If lstTemplates.ListIndex 0 And lstTemplates.Value < "" Then
WorkbookName = Worksheets("Table").Range("B" &
(lstTemplates.ListIndex + 1)) & _
"\" & Worksheets("Table").Range("C" & (lstTemplates.ListIndex +
1))
Workbooks.Open (WorkbookName)
Else
MsgBox ("No template is selected")
End If
End Sub

Macroes related to sheet "Start" ------------------------------------ end

Kind regards - Ebbe



Jim Rech

Why does Excel ask me to save changes?
 
Although something else may be going on here, this article explains some
possible causes.

http://support.microsoft.com/kb/274500/en-us

--
Jim
"Ebbe" wrote in message
...
Hi

I have a little workbook with two sheets.
On the sheet in the front (named Start) I have placed a ListBox (named
lstTemplates, ListFillRange:Tabel!A:A) and a CommandBottom (named
cmdSelect) and a CommandBottom (named cmdCancel).
On the sheet in the background (named Table) I have the data used to fill
in the listbox and the macros below.

If I open the workbook and immediately clicks on cmdCancel, the Excel asks
me if I want to save changes.
To avoid this question I have to uncomment the "ActiveWorkbook.Save".

Why is it necessary to save? I haven't changed anything!
Is there a way to avoid the "'ActiveWorkbook.Save" before the
"Application.Quit"?
I have tried with a "ActiveWorkbook.Close SaveChanges = False", but the
"Application.Quit" didn't execute.
The .xls file will be placed in a writeprotected area, therefor the
"ActiveWorkbook.Save" will be a bad idear to use.

Macroes related to sheet "Start" ------------------------------------
begin
Private Sub cmdCancel_Click()
If Workbooks.Count 1 Then
ActiveWorkbook.Close SaveChanges = False
Else
'ActiveWorkbook.Save
Application.Quit
End If
End Sub

Private Sub cmdSelect_Click()
OpenTemplate
End Sub

Private Sub lstTemplates_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
OpenTemplate
End Sub

Private Sub OpenTemplate()
Dim WorkbookName As String
Dim i As Integer
If lstTemplates.ListIndex 0 And lstTemplates.Value < "" Then
WorkbookName = Worksheets("Table").Range("B" &
(lstTemplates.ListIndex + 1)) & _
"\" & Worksheets("Table").Range("C" & (lstTemplates.ListIndex +
1))
Workbooks.Open (WorkbookName)
Else
MsgBox ("No template is selected")
End If
End Sub

Macroes related to sheet "Start" ------------------------------------ end

Kind regards - Ebbe




Ebbe[_2_]

Why does Excel ask me to save changes?
 
Hi Jim

After reading Your link, I have discovered that the reason to the prompt is
the information in the property "ListFillRange=Tabel!A:A" in the ListBox
"lstTemplates".
Leaving the proporty blank causes workbook to close propperly without a
prompt.
The filling in the listbox will course Excel to belive that the workbook is
changed.
Can I in any way persuade Excel that it does not have to prompt, when
changes is made in exatly this workbook?

Ebbe

"Jim Rech" skrev i en meddelelse
...
Although something else may be going on here, this article explains some
possible causes.

http://support.microsoft.com/kb/274500/en-us

--
Jim
"Ebbe" wrote in message
...
Hi

I have a little workbook with two sheets.
On the sheet in the front (named Start) I have placed a ListBox (named
lstTemplates, ListFillRange:Tabel!A:A) and a CommandBottom (named
cmdSelect) and a CommandBottom (named cmdCancel).
On the sheet in the background (named Table) I have the data used to fill
in the listbox and the macros below.

If I open the workbook and immediately clicks on cmdCancel, the Excel
asks me if I want to save changes.
To avoid this question I have to uncomment the "ActiveWorkbook.Save".

Why is it necessary to save? I haven't changed anything!
Is there a way to avoid the "'ActiveWorkbook.Save" before the
"Application.Quit"?
I have tried with a "ActiveWorkbook.Close SaveChanges = False", but the
"Application.Quit" didn't execute.
The .xls file will be placed in a writeprotected area, therefor the
"ActiveWorkbook.Save" will be a bad idear to use.

Macroes related to sheet "Start" ------------------------------------
begin
Private Sub cmdCancel_Click()
If Workbooks.Count 1 Then
ActiveWorkbook.Close SaveChanges = False
Else
'ActiveWorkbook.Save
Application.Quit
End If
End Sub

Private Sub cmdSelect_Click()
OpenTemplate
End Sub

Private Sub lstTemplates_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
OpenTemplate
End Sub

Private Sub OpenTemplate()
Dim WorkbookName As String
Dim i As Integer
If lstTemplates.ListIndex 0 And lstTemplates.Value < "" Then
WorkbookName = Worksheets("Table").Range("B" &
(lstTemplates.ListIndex + 1)) & _
"\" & Worksheets("Table").Range("C" & (lstTemplates.ListIndex
+ 1))
Workbooks.Open (WorkbookName)
Else
MsgBox ("No template is selected")
End If
End Sub

Macroes related to sheet "Start" ------------------------------------ end

Kind regards - Ebbe






Jim Rech

Why does Excel ask me to save changes?
 
Can I in any way persuade Excel that it does not have to prompt

This should do it:

ActiveWorkbook.Saved = True

--
Jim



Ebbe[_2_]

Why does Excel ask me to save changes?
 
Hi Jim

It does not work :-(

I am making a work-around by saving the workbook in a temporary directory
and deleting it afterwards.

BUT it would be better if a more "correct" solution is found.

Ebbe

"Jim Rech" skrev i en meddelelse
...
Can I in any way persuade Excel that it does not have to prompt


This should do it:

ActiveWorkbook.Saved = True

--
Jim




jhr_2005

Why does Excel ask me to save changes?
 
It worked for me. Thanks, this is just what I needed.

"Jim Rech" wrote:

Can I in any way persuade Excel that it does not have to prompt


This should do it:

ActiveWorkbook.Saved = True

--
Jim





All times are GMT +1. The time now is 09:20 PM.

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