简体   繁体   中英

Using other workbook macros: Tools - References in VBA

I'm using another workbook as a library of common routines (Tools - References - etc). It works just fine.

However, when the caller file loads it as a reference it also opens the library file on the background. Two questions:

  • Is it possible to make the loaded library read only?
  • Is it possible to hide the loaded library hidden from the user?

You can set the read-only attribute (in File Explorer's File Properties dialog) on any of the workbooks, including the referenced workbook, regardless of whether that is a normal macro-enabled workbook, or a macro-enabled add-in.

There isn't anyway to make a referenced workbook not appear in the VBE Project Explorer, but you can "protect" it with a password so that it can't easily be explored, but note that password protections are very easily defeated, so assume that determined users will be able to browse and change your code.

If you need better protections, and you'd like the reference to only appear in the references list and not in the Project Explorer, then you'll need to implement the reference as a COM Type Libarary, and install it on each machine upon which it is required. It's more effort, but it also offers much better protection.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM