Programmatically Add macro event to object in PPT

K

kerb

In VB.net, I am trying to add an object (button) from the control toolbox on
a slide, and then I want to add the click and other events to it via VB.net.
When I try to add code to the object it gets put in a new module rather than
in the slide area when you view the VB editor.

For instance, (in vb.net)
-------------------------------
dim msg as string="hello"

dim s as string = _
"Private Sub CommandButton1_Click()" & vbcrlf & _
" ' some code here" & vbcrlf & _
"End Sub" & vbcrlf

oPres.VBProject.VBComponents.Add(Microsoft.Vbe.Interop.vbext_ComponentType.vbext_ct_StdModule).CodeModule.AddFromString(s)
----------------------------------

But this does not add the macro to the right area. It adds a new module.
To see what it should look like, if you place a button on a slide and then
click on it, you can see where this same code is placed.

Thanks
 

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