Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Test If Add-In Workbook is being Referenced

I have an Add-In Workbook that contains userforms and code which is
referenced by other workbooks. This is my problem, I may have 4 workbooks
open referencing the add-in wbk. If all those workbooks close, but the Excel
application remains open, my add-in does not close. Is there a way to put
code in the add in wbk to check to see if any workbooks are referencing it
and if not close the add-in?

Thanks in Advance!
--
Cheers,
Ryan
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 5,600
Default Test If Add-In Workbook is being Referenced

AFAIK there is no direct way for an addin to know if all other workbooks
that reference it have closed (by reference I assume you mean UDFs, though
the same would apply if you meant tools/ref's).

If it's important to you, the open event of any workbook that references the
xla could increment some cell in the xla'a sheet. When the workbook closes
it could decrement the counter. A change event in the xla could close itself
if the counter reaches zero.

Personally I'd be inclined to allow the xla to stay open and not worry about
it!

Regards,
Peter T


"Ryan H" wrote in message
...
I have an Add-In Workbook that contains userforms and code which is
referenced by other workbooks. This is my problem, I may have 4 workbooks
open referencing the add-in wbk. If all those workbooks close, but the
Excel
application remains open, my add-in does not close. Is there a way to put
code in the add in wbk to check to see if any workbooks are referencing it
and if not close the add-in?

Thanks in Advance!
--
Cheers,
Ryan



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Test If Add-In Workbook is being Referenced

Try
Msgbox AddIns("analysis toolpak").Installed

'You can check for the other available Add-Ins
Sub Macro()
For Each myAddin In Application.AddIns
If myAddin.Name = "ATPVBAEN.XLA" Then
MsgBox myAddin.Installed
End If
Next
End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Ryan H" wrote:

I have an Add-In Workbook that contains userforms and code which is
referenced by other workbooks. This is my problem, I may have 4 workbooks
open referencing the add-in wbk. If all those workbooks close, but the Excel
application remains open, my add-in does not close. Is there a way to put
code in the add in wbk to check to see if any workbooks are referencing it
and if not close the add-in?

Thanks in Advance!
--
Cheers,
Ryan

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default Test If Add-In Workbook is being Referenced

Ryan, have you tried this; if this does not work let me know...

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try
Msgbox AddIns("analysis toolpak").Installed

'You can check for the other available Add-Ins
Sub Macro()
For Each myAddin In Application.AddIns
If myAddin.Name = "ATPVBAEN.XLA" Then
MsgBox myAddin.Installed
End If
Next
End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Ryan H" wrote:

I have an Add-In Workbook that contains userforms and code which is
referenced by other workbooks. This is my problem, I may have 4 workbooks
open referencing the add-in wbk. If all those workbooks close, but the Excel
application remains open, my add-in does not close. Is there a way to put
code in the add in wbk to check to see if any workbooks are referencing it
and if not close the add-in?

Thanks in Advance!
--
Cheers,
Ryan

  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 489
Default Test If Add-In Workbook is being Referenced

Sorry for the slow response Jacob. I tried this code below and it doesn't
seem to find my add-in.

Sub FindAddIn()

Dim myAddin As Variant

For Each myAddin In Application.AddIns
If myAddin.Name = "QG Add-In.xla" Then
MsgBox myAddin.Installed
End If
Debug.Print myAddin.Name
Next

End Sub

This is what was printed in the Immediate Window:
ANALYS32.XLL
ATPVBAEN.XLA
SUMIF.XLA
EUROTOOL.XLA
EG2000.xla
HTML.XLA
LOOKUP.XLA
SOLVER.XLA

Let me explain exactly what I'm looking for maybe you can give me another
clue of what to do. I have a workbook named "QUOTE GENERATOR.xls". I added
a Reference workbook by selecting ToolsReferences then selected "QG
Add-In.xla" in the VBA Editor. "QG Add-In.xla" contains all of the code and
userforms and "QUOTE GENERATOR.xls" stores data to be used in the userforms.
Sometimes there may be instances where "QUOTE GENERATOR.xls" is open multiple
times and all of those instances access the "QG Add-In.xla". The problem is
when all the copies of "QUOTE GENERATOR.xls" are closed, but Excel
Application is not closed the "QG Add-In.xla" remains open. I would like to
have code that can detect if any workbooks are referencing "QG Add-In.xla",
is that possible?

--
Cheers,
Ryan


"Jacob Skaria" wrote:

Ryan, have you tried this; if this does not work let me know...

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Try
Msgbox AddIns("analysis toolpak").Installed

'You can check for the other available Add-Ins
Sub Macro()
For Each myAddin In Application.AddIns
If myAddin.Name = "ATPVBAEN.XLA" Then
MsgBox myAddin.Installed
End If
Next
End Sub



If this post helps click Yes
---------------
Jacob Skaria


"Ryan H" wrote:

I have an Add-In Workbook that contains userforms and code which is
referenced by other workbooks. This is my problem, I may have 4 workbooks
open referencing the add-in wbk. If all those workbooks close, but the Excel
application remains open, my add-in does not close. Is there a way to put
code in the add in wbk to check to see if any workbooks are referencing it
and if not close the add-in?

Thanks in Advance!
--
Cheers,
Ryan

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
Ribbon Button not Working with my Referenced Workbook RyanH Excel Programming 2 October 7th 08 06:08 PM
Rowsource referenced to a hidden workbook borg Excel Programming 1 April 13th 06 12:15 AM
Closing a referenced workbook Frederick Chow Excel Programming 0 January 3rd 06 04:26 PM
Workbooks referenced by a deleted workbook Triggerfish[_2_] Excel Programming 1 February 13th 04 09:44 PM
Workbook referenced by a deleted workbook Triggerfish Excel Programming 0 February 13th 04 06:09 PM


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