IMPORT ThisWorkBook.cls file when coming...

drom

Well-known Member
Joined
Mar 20, 2005
Messages
528
Office Version
  1. 2021
  2. 2019
  3. 2016
  4. 2013
  5. 2011
  6. 2010
  7. 2007
Hi and Thanks in advance!

ref.: IMPORT ThisWorkBook.cls file when coming from explorer with a different name.

When I import from a folder "eg: C:\MrExcel" a few .CLS, files using:

Code:
  For X = LBound(aFiles) To UBound(aFiles)
    FxName = Left(aFiles(X), InStrRev(aFiles(X), ".") - 1)
      If LCase(Right(aFiles(X), 4)) = ".cls" Then
        With ActiveWorkbook.VBProject
          .VBComponents.Remove .VBComponents(FxName)
          .VBComponents.Import aFiles(X)
        End With
      End If
    FxName = ""
  Next X

is there any way to know if the imported file that goes to the ClassModule place, is a ThisWorkBook Module and not a sheet module or a Class module?

When you change the name of the ThisWorkBook.CLS file using Explorer to say "MyThisWKB.CLS"
If you import this File "ThisWKB.CLS":
Excel Knows ThisWKB.cls is a ThisWorkbook module file, because the imported file comes with a different name than ThisWKB.

How does it excel excel know if is a ThisWorkBook module file?
 

Excel Facts

Workdays for a market open Mon, Wed, Friday?
Yes! Use "0101011" for the weekend argument in NETWORKDAYS.INTL or WORKDAY.INTL. The 7 digits start on Monday. 1 means it is a weekend.

Forum statistics

Threads
1,214,920
Messages
6,122,264
Members
449,075
Latest member
staticfluids

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top