I have a problem with organizing my CATIA macros and I can not find a suitable solution for it.
At the moment I have a large project that grew from smaller one in time. It is 10k lines big and it is written in one module. I would like to make it more readable and easier to modify / navigate by creating multiple commented modules. I have my "Main" module and GUI that would call other modules. Problem is that CATIA makes every module I create accessible to use as a macro. I do not want that because I want user to make a shortcut for my Main module. I do not need to hide my code but it would be very hard to explain new user which macro he/she would need to use if the got 20 macros when importing one project.
I tried with "option private module" and even using password but I can not reduce number of available macros in that list. Only solution I can think of (and it is crazy) is to put every procedure/function in separate class.
any experience or thought about this problem is welcome.
Thanks in advance! :)
There is absolutely nothing whatsoever that is crazy about refactoring your procedural code into class modules. In fact, I would even go as far as calling it a best practice.
Your macros can all look like this:
Public Sub DoSomething()
With New MyAwesomeMacro
.Execute
End With
End Sub
Public Sub DoAnotherThing()
With New SomeOtherMacro
.Execute
End With
End Sub
'...
So you have a MyAwesomeMacro
class module with an Execute
procedure (which can take arguments as needed):
Option Explicit
Public Sub Execute()
'the old macro code here...
End Sub