Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Run macro before closing Excel 2007

Hi

I can read a lot of posts regarding Workbook_BeforeClose but can't quit find
the answer to problem.
When using Workbook_BeforeClose it's run when closing the active worksheet
and leaves Excel running without any open worksheets. I need a macro that
runs when the user closes Excel not just the worksheet.
I run a macro that installs a add-in through Workbook_Open and I want to
remove the add-in when the user closes Excel?

/Lasse
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run macro before closing Excel 2007


Workbook_BeforeClose event only runs when the workbook is closed, yo
cannot "close" the activesheet unless changing to another, it's a bi
harsh but you can use Application.Quit which closes the whol
application.

What is it that you are running that wont allow the shell of excel t
close? can you supply the code from your Workbook_BeforeClose

--
The Code Cage Tea

Regards,
The Code Cage Team
www.thecodecage.co
-----------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=695

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Run macro before closing Excel 2007

Hi

I have a Workbook_Open() in Personal.xlsb where I run the following code:
Set MyAddIn = AddIns.Add(Filename:="C:\Excel\addin.xlam", CopyFile:=True)
AddIns("AddIn_Name").Installed = True

I would like the add-in to get removed when closing Excel completely and not
just when closing a worksheet. I need the add-in to be accessible as long as
the user has Excel running.

I would like the following macro to run when Excel is closed:
AddIns("AddIn_Name").Installed = False

The reason is that if the addin.xlam file is missing for some reason I do a
check in Workbook_Open that copies it from the network, this works fine but
Excel returns a error messeage when opening and the .xlam file is missing. So
my idea was to unload the add-in before exit each time so that Excel won't
complaint if the file is missing.

I hope this makes sense :-)

/Lasse

"The Code Cage Team" wrote:


Workbook_BeforeClose event only runs when the workbook is closed, you
cannot "close" the activesheet unless changing to another, it's a bit
harsh but you can use Application.Quit which closes the whole
application.

What is it that you are running that wont allow the shell of excel to
close? can you supply the code from your Workbook_BeforeClose?


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=6952


  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run macro before closing Excel 2007


Perhaps something like:
If AddIns("YOUR Add-in").Installed = True Then
AddIns("YOUR Add-in").Installed = False
End If


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=6952

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Run macro before closing Excel 2007

Hi again

I have tried the code you suggest but if I put it in Workbook_BeforeClose it
will remove the add-in if just the active workbook is closed, I only want it
to remove the add-in if Excel is closed.
If a user opens a workbook and then wants to close it without closing Excel
so he/she can open a new workbook the add-in has to be present.

/Lasse

"The Code Cage Team" wrote:


Perhaps something like:
If AddIns("YOUR Add-in").Installed = True Then
AddIns("YOUR Add-in").Installed = False
End If


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=6952




  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run macro before closing Excel 2007


I kind of understand what you are getting at but if you have the code in
the PERSONAL.xlsm Workbooks_Open event then EVERY workbook that is
opened should have the add-in installed regardless of whether a
Workbook_BeforeClose has just uninstalled it because a workbook hase
been closed!

Does the add-in really have to be uninstalled?


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=6952

  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 15
Default Run macro before closing Excel 2007

So far thanks for your input, it's greatly appreciated! Maybe I should get a
profile on your site :-)

The only reason I want to uninstall the add-in is to avoid getting a
build-in error message from Excel if the add-in.xlam file is missing when
opening Excel. The build-in message appears before Excel runs the content of
ThisWorkbook so I assume that I can't suppress it.

I have just tried adding the following to ThisWorkbook in Personal.xlsb:
Private Sub Workbook_BeforeClose(Cancel As Boolean)
AddIns("Add-in").installed = False
Msgbox "Add-in uninstalled"
End Sub

But it never executes it when closing a worksheet og Excel?

/Lasse
  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Run macro before closing Excel 2007


Yes feel free to join our site!
You will have to use error trapping to handle the error as it occurs,
i'll take a look and get back to you ;)


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile: http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=6952

  #9   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 449
Default Run macro before closing Excel 2007

Lasse

Turn your Personal.xlsb into MyAddin.xlam, and install it, for the desired
behavior.

HTH. Best wishes Harald


"Lasse" wrote in message
...
Hi again

I have tried the code you suggest but if I put it in Workbook_BeforeClose
it
will remove the add-in if just the active workbook is closed, I only want
it
to remove the add-in if Excel is closed.
If a user opens a workbook and then wants to close it without closing
Excel
so he/she can open a new workbook the add-in has to be present.

/Lasse

"The Code Cage Team" wrote:


Perhaps something like:
If AddIns("YOUR Add-in").Installed = True Then
AddIns("YOUR Add-in").Installed = False
End If


--
The Code Cage Team

Regards,
The Code Cage Team
www.thecodecage.com
------------------------------------------------------------------------
The Code Cage Team's Profile:
http://www.thecodecage.com/forumz/member.php?userid=2
View this thread: http://www.thecodecage.com/forumz/showthread.php?t=6952



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
Closing Excel 2007 Yaz Excel Discussion (Misc queries) 6 February 12th 10 01:32 PM
Closing Excel 2007 skiterry Excel Discussion (Misc queries) 4 August 7th 08 07:11 PM
Excel 2007 Craches when closing via macro code Corey Excel Programming 3 December 25th 07 05:20 PM
Excel 2007 closing Keith Excel Discussion (Misc queries) 2 December 10th 07 03:02 PM
CLosing Excel 2007 with personal macro workbook Kato Wilbur Excel Discussion (Misc queries) 3 March 13th 07 09:59 PM


All times are GMT +1. The time now is 06:54 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"