Forum Discussion
perkin_warbeck
Mar 05, 2024Brass Contributor
Why do vba worksheet modules export as .cls modules?
I would like to clean up my Excel VBA project by exporting all code modules and then re-importing them. I understand that there is no VBA Project export or import, and that this must be done one modu...
perkin_warbeck
Mar 05, 2024Brass Contributor
Thank you for sharing your code. In function ModuleTypeExt, Worksheet or Workbook objects are exported without an extension. They will be imported as class modules, which is wrong. That's the problem I'm trying to solve: how to export and import Worksheet or Workbook objects. So maybe it's impossible.
HansVogelaar
Mar 05, 2024MVP
Worksheet and workbook modules ARE class modules, but not stand-alone class modules. You cannot use File > Import to import them to a worksheet or workbook. You have to copy/paste the text.
- perkin_warbeckMar 05, 2024Brass ContributorThank you. I'm beginning to understand now. Copying and pasting text of worksheet and workbook modules is a very simple solution. However I wonder if it accomplishes my goal of "cleaning up" an application.
Suppose that I have exported Sheet1 module. Now, I delete all the text in the Sheet1 module and recompile project. Then I copy and paste the text from Sheet1.cls (just the code) into the Sheet1 module. Does this accomplish anything? How is it different from ctrl-A, ctrl-X, ctrl-V? Surely that doesn't do any real cleanup, does it?- HansVogelaarMar 05, 2024MVP
Compiling after deleting the code should remove the 'fluff' that builds up over time.