Add macro to slide with .Net

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
 
S

Shyam Pillai

Hi,
You cannot explicitly add a document module associated with a slide in
PowerPoint. When you add a active control on the slide, the document module
is inserted automaticallty. To add code into it, you will need to retreive
the reference. The VBComponent type to check for is vbext_ct_Document and
check it's name property.


--
Regards,
Shyam Pillai

Animation Carbon: Copy/Paste/Share animation libraries.
www.animationcarbon.com
 

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