Add a button to the Excel sheet

G

Guest

Hi all,

I would like to add a button to the excel sheet dynamically and this button
is to be used to navigate between sheets.

Thnx in Advance
 
A

Alvin Bruney - ASP.NET MVP

What excel control are you using? If you are simply changing the
content-type, it can't be done. If you are working with a live object
instance such as the Office Web Controls, add the tab thru the sheet's add
method. Buttons are not supported on the Excel surface. If you are using
interop and COM, the same procedure holds true.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 
G

Guest

Jaison,
I appologize for just guessing cause I don't have excel on the home
computer. I have done this so many times I'm going to try and help.

I would make an invisible button then dynamically set the visible property
to true.

Draw the button on the sheet
set the button visible property to false
dynamically make the button visible by setting the visible property to true.

Good Luck
DWS
 
G

Guest

Hi Alvin and DWS,
Thanks for showing intrest in answering my question.
I have added the button using thee code below.

Excel.Shape shape=
xWS.Shapes.AddOLEObject("Forms.CommandButton.1", Missing.Value,
Missing.Value,Missing.Value,Missing.Value,Missing.Value,Missing.Value,
xWS.get_Range("G2", Missing.Value).Left,
xWS.get_Range("G2", Missing.Value).Top,100, 40);





I created an object for MSForms and changed the caption... But that doenot
work. Can any1 plZ suggest me a way to solve this issue.

I also wanna write a simple code to handle the button event.



--
Cheers

Jaison


Alvin Bruney - ASP.NET MVP said:
What excel control are you using? If you are simply changing the
content-type, it can't be done. If you are working with a live object
instance such as the Office Web Controls, add the tab thru the sheet's add
method. Buttons are not supported on the Excel surface. If you are using
interop and COM, the same procedure holds true.

--
Regards,
Alvin Bruney [MVP ASP.NET]

[Shameless Author plug]
The Microsoft Office Web Components Black Book with .NET
Now Available @ www.lulu.com/owc
Forth-coming VSTO.NET - Wrox/Wiley 2006
 

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

Members online

No members online now.

Forum statistics

Threads
473,744
Messages
2,569,484
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top