Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 119
Default Trying to Close File

I added some code in an Excel file that told me whether I was done with the
active sheet or not. Basically, if I entered all the information I needed,
the tab colour would be green. Otherwise, it would be red. I used a
Workbook_SheetChange event and called a module that had the code. Upon
closing the file, I got prompted to save. I clicked Yes, it saved, and
reprompted me to save endlessly.

Basically, the code for the colour change was this:

ActiveSheet.Tab.Color = RGB (Insert colour code)

When I go to save, the Saved property is false. I have since taken the
colour code out, and it works fine. What am I missing? I would really like
this to work, as it is very handy as opposed to going to my Summary tab to
see what tabs need info.

TIA.
--
I am running on Office 2003, unless otherwise stated.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default Trying to Close File

Hello Orion,

I think your problem is that the worksheet change event is recalling iself
due to changes being made by the code within the event.

Try putting the following line of code as the first line after the sub name
Application.EnableEvents = False

then put the following line to be processed last in the code

Application.EnableEvents = True

Now there is just one little problem. If during testing,your code fails
after the first line but before reaching the last line then events remain
turned off until an excel restart or you run code to turn it on. Therefore
include the following sub anywhere in the VBA editor and run it from the VBA
editor if this occurs. To run it from the VBA editor, click anywhere in the
sub and press F5. You can leave the sub there for use anytime at a later date
if you are doing modifications to your code.

Sub ReEnableEvents
Application.EnableEvents = True
EndSub

--
Regards,

OssieMac


"Orion Cochrane" wrote:

I added some code in an Excel file that told me whether I was done with the
active sheet or not. Basically, if I entered all the information I needed,
the tab colour would be green. Otherwise, it would be red. I used a
Workbook_SheetChange event and called a module that had the code. Upon
closing the file, I got prompted to save. I clicked Yes, it saved, and
reprompted me to save endlessly.

Basically, the code for the colour change was this:

ActiveSheet.Tab.Color = RGB (Insert colour code)

When I go to save, the Saved property is false. I have since taken the
colour code out, and it works fine. What am I missing? I would really like
this to work, as it is very handy as opposed to going to my Summary tab to
see what tabs need info.

TIA.
--
I am running on Office 2003, unless otherwise stated.

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
Everytime i close an excel file, it creates a new backup file p Excel Discussion (Misc queries) 3 November 22nd 07 08:13 AM
Close & save a file at set time only IF the file is open Clivey_UK[_5_] Excel Programming 2 May 1st 06 06:19 PM
Close file and run macro from newly opened file Pradip Jain Excel Programming 1 April 23rd 05 11:39 PM
VBA - on a button event, open another closed file, post changes, close file Fio Excel Programming 0 March 1st 04 01:08 PM
Automate open file, update links, run macro, close and save file Geoff[_7_] Excel Programming 2 August 26th 03 10:13 PM


All times are GMT +1. The time now is 08:56 PM.

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

About Us

"It's about Microsoft Excel"