Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Excel VBA > Excel VBA
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Excel VBA Discuss using VBA for Excel programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Excel VBA section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old May 1st, 2008, 02:25 PM
Registered User
 
Join Date: May 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Code to execute before application (excel) quits

Hi,
Would like to know if there is anyway to execute a piece of code before the application exits.

To be more specific, am looking for executing before application exits and not before workbook close.

Thanks.

Reply With Quote
  #2 (permalink)  
Old May 6th, 2008, 02:35 PM
Friend of Wrox
Points: 513, Level: 8
Points: 513, Level: 8 Points: 513, Level: 8 Points: 513, Level: 8
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Feb 2007
Location: Davenport, IA, USA.
Posts: 163
Thanks: 0
Thanked 2 Times in 2 Posts
Default

The macro language for Excel is meant to work on workbooks and are a part of that workbook project in the VBA editor. The way to handle this is to have the code execute from the Personal.xls hidden book that contains your macros for all workbooks.

There is a hidden workbook that stores your local macros. The before workbook close for this project should only fire when Excel itself is closed. Putting your code for before workbook close in this project should accomplish what you want since Personal.xls normally always opens when you open Excel and only closes when Excel is closed.

Hope this helps.

Reply With Quote
  #3 (permalink)  
Old May 7th, 2008, 08:10 AM
Registered User
 
Join Date: May 2008
Location: , , .
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks Allen.

I suppose adding code to the Personal.xls will really help but I don't see that Excel workbook on the VBA Editor's Project Explorer. How do I view it so that I can place my code under appropriate event.

Reply With Quote
  #4 (permalink)  
Old May 7th, 2008, 09:45 PM
Friend of Wrox
Points: 3,060, Level: 23
Points: 3,060, Level: 23 Points: 3,060, Level: 23 Points: 3,060, Level: 23
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Sep 2005
Location: , , .
Posts: 812
Thanks: 1
Thanked 53 Times in 49 Posts
Default

Hi

The PErsonal.xls will be available in c:\Documents and Settings\Your UserName\Application Data\Microsoft\Excel\xlstart
The Excel workbook in XLStart folder will be opened by Excel when an instance is created.

If there is no Excel there, you can create a new workbook and save it in this folder

Cheers
Shasur

http://www.dotnetdud.blogspot.com

VBA Tips & Tricks (http://www.vbadud.blogspot.com)
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Resolved! - code behind button won't execute dartcoach Access VBA 1 February 4th, 2008 06:17 PM
execute an excel macro via a .vbs file ismailc VB.NET 2002/2003 Basics 1 January 11th, 2007 04:19 PM
Execute Code Once Only brettk_1 Classic ASP Professional 5 May 29th, 2006 09:31 AM
Store a value to a variable until user quits Acces Sharq Access VBA 7 January 7th, 2004 10:18 AM
How to execute data using VB in excel rachelrekkab Excel VBA 1 August 15th, 2003 06:54 AM



All times are GMT -4. The time now is 07:05 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.