CommandButton Caption

  • Thread starter Thread starter kar3n.chandra
  • Start date Start date
K

kar3n.chandra

Hey!
i have a c# program opening and creating powerpoint slides and i
created a commandbutton on the slide. the problem i'm having is
changing the caption of the button.
i've placed the code below and the only error is
objValue.Caption="Values". when i run the program, the powerpoint
crashes at that command.


PowerPoint.Shape vButton = newSlide.Shapes.AddOLEObject(10, 500, 100,
30,"Forms.CommandButton.1",null,MsoTriState.msoFalse,null,0,null,MsoTriState.msoFalse);
vButton.Name = "cmdValue";
MSForms.CommandButton vButtObj =
(MSForms.CommandButton)vButton.OLEFormat.Object;
vButtObj.Caption = "Values";

any idea on what i'm doing wrong?
 
finally figured it out.. and hope this helps someone.. :)

PowerPoint.Shape vButton = currentSlide.Shapes.AddOLEObject(10, 500,
60, 30, "Forms.CommandButton.1", null, MsoTriState.msoFalse, null, 0,
null, MsoTriState.msoFalse);
vButton.Name = "cmdValues";
MSForms.CommandButton vButtObj =
(MSForms.CommandButton)vButton.OLEFormat.Object;
vButton.GetType().InvokeMember("Caption", BindingFlags.SetProperty,
null, vButtObj, new object[] { "Values" });
 

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

Back
Top