Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 9
Default VBA References

I have a workbook that references an add-in. I am trying
to close the add-in when I close the workbook, but I
can't get it to work. I just get the message that "This
workbook is currently referenced by another workbook and
cannot be closed." I've tried putting the code in the
BeforeClose event, but since the workbook is technically
not closed yet, it still doesn't work.

Any Suggestions?
TT
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default VBA References

TT,

You could do something like:

With ThisWorkbook.VBProject
.References.Remove .References("MyVBAProject")
End With
MyVBAProject.ThisWorkbook.Close

Be sure not to save changes to your own workbook, else the reference is gone
for good!

Rob


"Tommy T" wrote in message
...
I have a workbook that references an add-in. I am trying
to close the add-in when I close the workbook, but I
can't get it to work. I just get the message that "This
workbook is currently referenced by another workbook and
cannot be closed." I've tried putting the code in the
BeforeClose event, but since the workbook is technically
not closed yet, it still doesn't work.

Any Suggestions?
TT



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default VBA References

Thanks Rob. Is there a way I can bring up the save
prompt (not the saveas dialog box) before I do this?
That way, I could have the user choose to save their
changes, but I would then set the displayalerts property
to false before I removed the reference.


-----Original Message-----
TT,

You could do something like:

With ThisWorkbook.VBProject
.References.Remove .References("MyVBAProject")
End With
MyVBAProject.ThisWorkbook.Close

Be sure not to save changes to your own workbook, else

the reference is gone
for good!

Rob


"Tommy T" wrote in

message
...
I have a workbook that references an add-in. I am

trying
to close the add-in when I close the workbook, but I
can't get it to work. I just get the message

that "This
workbook is currently referenced by another workbook

and
cannot be closed." I've tried putting the code in the
BeforeClose event, but since the workbook is

technically
not closed yet, it still doesn't work.

Any Suggestions?
TT



.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA References

Why make it complex, create the reference in the workbook_Open event.
Remove it in the beforeclose event. In either case, you can check if it
exists before doing anything.

Excel will bring up the save prompt and if you do the above, that will be
appropriate.

--
Regards,
Tom Ogilvy

Tommy Y wrote in message
...
Thanks Rob. Is there a way I can bring up the save
prompt (not the saveas dialog box) before I do this?
That way, I could have the user choose to save their
changes, but I would then set the displayalerts property
to false before I removed the reference.


-----Original Message-----
TT,

You could do something like:

With ThisWorkbook.VBProject
.References.Remove .References("MyVBAProject")
End With
MyVBAProject.ThisWorkbook.Close

Be sure not to save changes to your own workbook, else

the reference is gone
for good!

Rob


"Tommy T" wrote in

message
...
I have a workbook that references an add-in. I am

trying
to close the add-in when I close the workbook, but I
can't get it to work. I just get the message

that "This
workbook is currently referenced by another workbook

and
cannot be closed." I've tried putting the code in the
BeforeClose event, but since the workbook is

technically
not closed yet, it still doesn't work.

Any Suggestions?
TT



.



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1,236
Default VBA References

You could set the Saved property to True in the BeforeClose event, that way
Excel doesn't complain.

Otherwise I think should do it:
If MsgBox("Save Changes?", vbYesNo) = vbYes Then ThisWorkbook.Save

Rob


"Tommy Y" wrote in message
...
Thanks Rob. Is there a way I can bring up the save
prompt (not the saveas dialog box) before I do this?
That way, I could have the user choose to save their
changes, but I would then set the displayalerts property
to false before I removed the reference.


-----Original Message-----
TT,

You could do something like:

With ThisWorkbook.VBProject
.References.Remove .References("MyVBAProject")
End With
MyVBAProject.ThisWorkbook.Close

Be sure not to save changes to your own workbook, else

the reference is gone
for good!

Rob


"Tommy T" wrote in

message
...
I have a workbook that references an add-in. I am

trying
to close the add-in when I close the workbook, but I
can't get it to work. I just get the message

that "This
workbook is currently referenced by another workbook

and
cannot be closed." I've tried putting the code in the
BeforeClose event, but since the workbook is

technically
not closed yet, it still doesn't work.

Any Suggestions?
TT



.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default VBA References

That is correct. You can't close a workbook that is referenced by another
workbook.

I would suggest removing the reference and closing the addin, but I don't
think the reference would actually be removed until the macro terminated.

--
Regards,
Tom Ogilvy

Tommy T wrote in message
...
I have a workbook that references an add-in. I am trying
to close the add-in when I close the workbook, but I
can't get it to work. I just get the message that "This
workbook is currently referenced by another workbook and
cannot be closed." I've tried putting the code in the
BeforeClose event, but since the workbook is technically
not closed yet, it still doesn't work.

Any Suggestions?
TT



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
How to convert all 3d references to normal references in a workboo Dima Excel Discussion (Misc queries) 6 August 8th 08 12:38 PM
How to convert all 3d references to normal references in a workboo Dima Excel Worksheet Functions 6 August 8th 08 12:38 PM
convert relative cell references to absolute cell references via amacro? Dave F[_2_] Excel Discussion (Misc queries) 1 May 15th 08 04:43 PM
Help with converting a block of cells with Absolute and mixed references to relative references Vulcan Excel Worksheet Functions 3 December 13th 07 11:43 PM
How to rename references from range names to cell references Abbas Excel Discussion (Misc queries) 1 May 24th 06 06:18 PM


All times are GMT +1. The time now is 10:29 AM.

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

About Us

"It's about Microsoft Excel"