create macro and place on menu using VBA

L

Larry

I want to be able to do two things: create a macro using VBA and assign
that macro as a button to a particular menu on a custom toolbar.

Let's say I'm starting with the text of the macro-to-be already in the
Clipboard. Is this possible?

Larry
 
P

Peter Hewett

Hi Larry

Yes you can. The first part is creating a reference to the "Microsoft Visual Basic for
Applications Extensibility 5.3" library.

The next part is determining in which Module the code should go and if it doesn't exist
create it. Likewise for the function/sub/property, you have to determine whether the
procedure exists, if it does what to do about it or add a new procedure. It can be a
little tricky as the online help aint that great (no surprise here) and aint that
intuitive either.

You then hook the macro to the appropriate menubar.

Over the years I developed a couple of different sets of code to do this. I have some
inline code that creates AutoNew and AutoOpen procedure and adds some code. I also have a
*much* easier to use set of class modules that makes this a lot more trivial. However,
there's a *lot* of code (5 class modules, 500 lines of code).

If either or both of these would be useful to you email me at:

nospaminnerword at xtra dot co dot nz

remove the "nospam" and replace dot with . and at with @. Also because I run two spam
filters (one at my ISP and one on my PC) you message will NOT get through unless you mark
the subject line: "microsoft.public.word.vba.general - VB Extensibility".

HTH + Cheers - Peter
 

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