Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7508675
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 29, 20262026-05-29T22:42:55+00:00 2026-05-29T22:42:55+00:00

I have an Excel 2010 macro application that is made up of several workbook

  • 0

I have an Excel 2010 macro application that is made up of several workbook files.

FileName (ProjectName)
VFApp.xlsm (VFAppVBA)
VFReportClasses.xlsm (VFReportVBA)
VFImportClasses.xlsm (VFImportVBA)
VFDataClasses.xlsm (VFDataVBA)
ZShared.xlsm (ZSharedVBA)

  • Shared is referenced by all the other workbooks.
  • Data is referenced by App, Report, & Import.
  • Report and Import are both referenced by App.

I’m trying to close all the referenced files when the App file is closed. This works for everything except ZShared.xlsm. For it I get the ‘This workbook is currently referenced by another workbook and cannot be closed.’ error.

The only semi-helpful info I found online was http://support.microsoft.com/kb/211856
and http://support.microsoft.com/default.aspx?scid=kb;en-us;159794. I added some logging to all the classes in ZShared. All instances of it’s classes are getting correctly terminated and I don’t have any workbook objects pointing to ZShared.

I even tried renaming the files like (http://www.allquests.com/question/3996335/Upgrading-Add-ins-from-XL2003-to-XL2007.html).

The weird thing is, if I manually open VFDataClasses.xlsm before opening VFApp.xlsm, then ZShared will close out correctly without error. If I just open VFApp.xlsm and let it open all the other referenced files, I get the above error.

Anybody have any suggestions for figuring out why Excel thinks the workbook is still referenced?

Clairification:

  • Each workbook references the others via Tools -> References.
  • ZShared consists of public classes and modules with public subs, functions, and constants as well as 3 global variables.
  • I’m not, that I know of, doing anything to reference ZShared’s workbooks or other Excel objects.
  • The global variables are in ZShared so I don’t have to recreate them in each App that references ZShared. They are handled via public InitializeGlobalClasses and TerminateGlobalClasses
  • I added an m_InstanceId to every class and debug logging to all Class_Initialize and Class_Terminate so I am 100% certain that all instances of the classes are being terminated correctly.

I wonder if it is possible Excel is creating some hidden reference to the workbook based on using a With statement or some such that isn’t being cleared correctly. On the other hand, it makes no sense that this would only happen if ZShared was not already open when the App started.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-29T22:42:56+00:00Added an answer on May 29, 2026 at 10:42 pm

    I never found an answer to why Excel thinks the file is still referenced. As a work-around I ended up doing 2 things.

    • Hid the ZShared workbook in Excel so normal users can’t see it.
    • Set ZShared to Read Only so I can replace the file with an updated version even if people still have it open.

    If anyone knows of a way to peer into Excel’s internals to see why its reference garbage collection is not working, I’d love to know.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a VB6/VBA application that hooks into Excel and loads a workbook. It
I'm using Excel 2010 and I have a macro that needs to load OData
I have an Excel 2010 workbook for financial records. On one worksheet, I have
I have made a new Excel 2010 Add-in project, with VS10. When I run
I have an old macro that was working fine on Excel 2003 but creates
I have a C# WPF (.NET 4.0) application that uses Excel interop to read
I have an excel tool that was made by someone before me. However, when
I have a rather complex Excel 2010 file that I automate using python and
Excel 2010. I have a C# app that has a dataset with multiple tables.
Quick one (hopefully) I have a column in excel 2010 that has either the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.