Code generation

Q

QuantDev

I have posted this question on <microsoft.public.excel.programming>
but did not get any answer.

Has anyone tackled this issue here?

---------------------------------------------------------------------

I would like to create standard code templates, from (something like)
a form specifying parameters for the code generation. For instance,
for new class modules, you could specify a Foo property of type String
(byval/optional and defaulting to "FooString") and a user defined Bar
property of type BarClass, to be optionally initialized, and then the
generated "FooClass" Class Module would look like:

''''''''''''''''''''''''''''''''''''''''''''''''''
'Class Module: FooClass
'Created by: Name Surname
'Date Created: 23/07/2004
'Description: Foo is a Foo Class Module
''''''''''''''''''''''''''''''''''''''''''''''''''
'PRIVATE DATA MEMBERS
'''''''''''''''''''''''''''''''''''''''''''''''''

private m_strFoo as String
private m_oBarClass as BarClass
'''''''''''''''''''''''''''''''''''''''''''''''''
'PROPERTIES
'''''''''''''''''''''''''''''''''''''''''''''''''

Property Get Foo() As String
Foo = m_strFoo
End Property

Property Let Foo(Byval strFoo As String)
m_strFoo = strFoo
End Property

Property Get Bar() As BarClass
set Bar = m_oBar
End Property

Property Let Bar(oBar As BarClass)
set m_oBar = oBar
End Property
'''''''''''''''''''''''''''''''''''''''''''''''''
'CONSTRUCTORS / DESTRUCTORS
'''''''''''''''''''''''''''''''''''''''''''''''''

Public Sub Initialize(oBar as BarClass, _
optional byval strFoo as string = "FooString")
m_strFoo = strFoo
set m_oBar = oBar
End Sub

Private Sub Class_Terminate()
Set m_oBar = Nothing
End Sub

'''''''''''''''''''''''''''''''''''''''''''''''''
'PUBLIC METHODS
'''''''''''''''''''''''''''''''''''''''''''''''''

'''''''''''''''''''''''''''''''''''''''''''''''''
'PRIVATE METHODS
'''''''''''''''''''''''''''''''''''''''''''''''''

''''' FooClass Class Module terminates here '''''

I had a look at <http://www.cpearson.com/excel/vbe.htm>, and I think
it is achievable, but has anyone already spent time on this? I don't
want to rewrite anything in a suboptimal way.
Is there any open source VBA editor I could use instead (even though I
doubt it would be as integrated and convenient as VBE)? Can I use the
*VB* editor to write VBA code within Excel .xls / .xla?

Any other comment welcome.

quantdev2004
 
A

Andrew Cushen

Hi-

Sorry I can't help you with the code templates issue-
although I would think you could easily build such a thing
as a VB6 Add-In. There is info on creating Add-Ins on
MSDN: http://msdn.microsoft.com/default.aspx , and if you
look at the available Project Types when you start VB6,
you'll see Add-In listed. Also, have a look at this page
about creating VB Add-Ins:
http://www.15seconds.com/issue/010828.htm

I don't know of any other editors specifically for VB/VBA,
but you could look into Source Code editors like
SlickEdit, Code Warrior et al, and see if they have any
support for VB.

You can write VB6 code in the VB6 editor, which will be
its own app, and will control Excel remotely; this is
known as Automation. There is tons of info on this in the
Excel VB Help & on the MSDN site.

You could also write a COM Add-In for Excel, again
entirely within VB6. see MSDN, or Google for details.

Finally, you COULD write VB6 code in VB, then Copy it &
Paste it into the Excel VBA editor- though I'm not sure
why you'd want to, and you'd spend a significant amount of
time stripping out code that references the Application,
etc.

HTH,

-Andrew
======================================================
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top