Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Office 2003 and Win XP;
I have a normal XLS file which runs hidden (Window-Hide). This file is run from a toolbar. This hidden file does things to other files from the toolbar and in the process some data gets written into the hidden file, but it is only needed temporarily. The hidden file is shared, so it is set to open read only by default using file properties. Apparently, it is not possible to code this file so when a user closes MS-Excel the hidden file will close itself without warnings, without messages, and without saving? i.e. just drop dead, quietly? I have tried all manner of the following in either and both the Before_Close and Before_Save events: Cancel = True Application.EnableEvents = False Application.DisplayAlerts = False ThisWorkbook.Saved = True ThisWorkbook.Close SaveChanges:= False No matter what I try, I ALWAYS get the save file question. If not impossible, please tell me how it can be done. Thanks much in advance from a very frustrated user. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I assume the workbook is being closed manually, since you are trying to use
the before close and before save methods to indicate the file is saved to reject changes. Otherwise, the ThisWorkbook.Saved = True would work if entered just before the close command in code. For some reason, it won't work in the before close/save execution. You might be able to work around it by putting a close button on the toolbar and close the file by code each time. Then it should work. "XP" wrote: Office 2003 and Win XP; I have a normal XLS file which runs hidden (Window-Hide). This file is run from a toolbar. This hidden file does things to other files from the toolbar and in the process some data gets written into the hidden file, but it is only needed temporarily. The hidden file is shared, so it is set to open read only by default using file properties. Apparently, it is not possible to code this file so when a user closes MS-Excel the hidden file will close itself without warnings, without messages, and without saving? i.e. just drop dead, quietly? I have tried all manner of the following in either and both the Before_Close and Before_Save events: Cancel = True Application.EnableEvents = False Application.DisplayAlerts = False ThisWorkbook.Saved = True ThisWorkbook.Close SaveChanges:= False No matter what I try, I ALWAYS get the save file question. If not impossible, please tell me how it can be done. Thanks much in advance from a very frustrated user. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Also, if being closed by code, have you tried this syntax?:
Workbooks("myFile.XLS").Close SaveChanges:=False "XP" wrote: Office 2003 and Win XP; I have a normal XLS file which runs hidden (Window-Hide). This file is run from a toolbar. This hidden file does things to other files from the toolbar and in the process some data gets written into the hidden file, but it is only needed temporarily. The hidden file is shared, so it is set to open read only by default using file properties. Apparently, it is not possible to code this file so when a user closes MS-Excel the hidden file will close itself without warnings, without messages, and without saving? i.e. just drop dead, quietly? I have tried all manner of the following in either and both the Before_Close and Before_Save events: Cancel = True Application.EnableEvents = False Application.DisplayAlerts = False ThisWorkbook.Saved = True ThisWorkbook.Close SaveChanges:= False No matter what I try, I ALWAYS get the save file question. If not impossible, please tell me how it can be done. Thanks much in advance from a very frustrated user. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks for the effort,
Yes, the file would be closed by the user, so having a close button on the toolbar would not work, since the users could circumvent this by closing normally, and they will. Even if instructed not to, they will, due to memory or whatever. I also tried the alternate close: Workbooks("myFile.XLS").Close SaveChanges:=False Nothing works. Any other ideas? "JLGWhiz" wrote: Also, if being closed by code, have you tried this syntax?: Workbooks("myFile.XLS").Close SaveChanges:=False "XP" wrote: Office 2003 and Win XP; I have a normal XLS file which runs hidden (Window-Hide). This file is run from a toolbar. This hidden file does things to other files from the toolbar and in the process some data gets written into the hidden file, but it is only needed temporarily. The hidden file is shared, so it is set to open read only by default using file properties. Apparently, it is not possible to code this file so when a user closes MS-Excel the hidden file will close itself without warnings, without messages, and without saving? i.e. just drop dead, quietly? I have tried all manner of the following in either and both the Before_Close and Before_Save events: Cancel = True Application.EnableEvents = False Application.DisplayAlerts = False ThisWorkbook.Saved = True ThisWorkbook.Close SaveChanges:= False No matter what I try, I ALWAYS get the save file question. If not impossible, please tell me how it can be done. Thanks much in advance from a very frustrated user. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
I think you have too many lines of code in your event handler, and they are
canceling out the close operation, so the hidden workbook doesn't actually close. Try the following: Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Saved = True End Sub -- Regards, Bill Renaud |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, Bill.
That was one of the very first things I did try; it fails, I still get the message box... Any other ideas? "Bill Renaud" wrote: I think you have too many lines of code in your event handler, and they are canceling out the close operation, so the hidden workbook doesn't actually close. Try the following: Private Sub Workbook_BeforeClose(Cancel As Boolean) ThisWorkbook.Saved = True End Sub -- Regards, Bill Renaud |
#7
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Strange. I set this up as a Read-Only file (using Explorer) on Windows ME
with Excel 2000 SP-3, and it works fine on my machine. I can open the file, unhide the workbook, make a change, hide the workbook, then exit Excel without getting any prompts. What version of Excel are you running? -- Regards, Bill Renaud |
#8
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Hi Bill,
Oddly enough, I tried the same thing you did, only at home. I just set up a read only hidden file, then I wrote to it from another file using code, to change its contents. It worked just fine. At home I am running Office 2003 with Win XP, just like at work. I'm going to try this test tomorrow at work and see if it works. If it does, then something else is at play that I'm not accounting for. Thanks for your help; I may post back again depending upon what I find... "Bill Renaud" wrote: Strange. I set this up as a Read-Only file (using Explorer) on Windows ME with Excel 2000 SP-3, and it works fine on my machine. I can open the file, unhide the workbook, make a change, hide the workbook, then exit Excel without getting any prompts. What version of Excel are you running? -- Regards, Bill Renaud |
#9
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Another idea:
If your shared, hidden workbook is really Read-Only, then maybe you should just use it that way. Create another temporary workbook to save temporary data and close that one when any macro is finished running. Then your hidden workbook will never have any changes to it, so there will be no prompts. -- Regards, Bill Renaud |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
MATCH/IF/OR/AND statements not what I need apparently | Excel Discussion (Misc queries) | |||
Apparently missing in Excel 2007 | Excel Discussion (Misc queries) | |||
I need help with a (apparently) very simple VBA script | Excel Programming | |||
My needs are simple-apparently, so am I | Excel Worksheet Functions | |||
Apparently Simple Question | Excel Programming |