PDA

View Full Version : Get Function / Sub list in macro module



nhmabv
05-03-2012, 11:36 AM
I have a macro with a lot of functions and subs inside of "NewMacros" under "Modules".
Is there a way to write a list of these to a file? EG

MyFunction1(arg1 as string) as string
MySub1()
MySub2(arg4 as boolean) as string
.
.
.
.
.
MyFunction(N)
I saw posts on the internet by Chip Pearson, but I cant make them work.
Maybe we can get fancy and include the number of lines too.
Thanks
Mike

fumei
05-03-2012, 12:23 PM
"I saw posts on the internet by Chip Pearson, but I cant make them work."

Please post a link.

What does not work?

Are you sure you have a reference to VBA Extensibility?

Have you googled this? There are many examples.

nhmabv
05-03-2012, 12:36 PM
I did the reference , the security setting and I get an error about subscript out of range. The error was where I referenced my module.
Mike

Frosty
05-03-2012, 02:44 PM
It really depends on why you want to do this. Do you *really* need to use the VBProject object module to do this on a regular basis? Or are you looking for a one-off in order to better organize your code?

If it's a one-off, you simply copy and paste the entirety of the code module into a word document, do some find/replace functions so that each paragraph containing "Sub " and "Function " gets formatted as Heading 1... and then use a TOC to show what you need to show. From there that would presumably be what you need in order to organize your module better.

If, considering the above, you can't get something to work... please post the code you are working with, and we can probably make some adjustments. But otherwise, I agree with Fumei... there are a lot of samples to do this stuff. We don't really want to start from scratch with a sample completely differently than the one you've been trying to make work.

fumei
05-03-2012, 06:46 PM
And I agree with Frosty. If this is a one-off, or even a three-off, just copy and paste the module contents and then sort, or format as you need.