IMPORT ThisWorkBook.cls file when coming...

drom

Active Member
Joined
Mar 20, 2005
Messages
491
Office Version
  1. 2019
  2. 2016
  3. 2013
  4. 2011
  5. 2010
  6. 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

Easy bullets in Excel
If you have a numeric keypad, press Alt+7 on numeric keypad to type a bullet in Excel.

Forum statistics

Threads
1,191,124
Messages
5,984,782
Members
439,910
Latest member
Flyingjoblo

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
Top