hi guys,
this is first posting on The Scripts network.
Guys,
i have built a shared addin for Excel 2003 using visual studio 2005 and C#. Till adding command bar and menu items, it was okay.
But now i want to add typical button on excel sheet programmatically, but nothing seems to working.
Is it possible that i can add typical button controls on excel sheet from program.
2 3577
Should be possible. Here's how I did it in Excel VBA: - Sub aBook()
-
'This Macro creates a workbook, a button, and a code module
-
Dim wb As Workbook
-
Dim ws As Worksheet
-
Dim s As Variant
-
Dim btn As OLEObject
-
Dim lLines As Long
-
' Hide VBE Window = No screen flashes
-
Application.VBE.MainWindow.Visible = False
-
' Create a new Workbook with one worksheet, Cmds
-
Set wb = Workbooks.Add
-
Set ws = Worksheets.Add
-
ws.Name = "Cmds"
-
Application.DisplayAlerts = False
-
For Each s In wb.Worksheets ' Delete the rest of the worksheets
-
If s.Name <> "Cmds" Then s.Delete
-
Next s
-
Application.DisplayAlerts = True
-
-
' Create a button
-
Set btn = ws.OLEObjects.Add(ClassType:="Forms.CommandButton.1", _
-
Left:=50, Top:=25, Width:=75, Height:=20)
-
btn.Name = "cmdWork"
-
btn.Object.Caption = "Press"
-
-
' Find the associated code module and create the click event handler
-
For Each s In wb.VBProject.VBComponents
-
If s.Name = ws.CodeName Then
-
With s.CodeModule
-
lLines = .CountOfLines
-
.InsertLines lLines + 1, "Sub cmdWork_Click()"
-
.InsertLines lLines + 2, " MsgBox ""Back to Work!"""
-
.InsertLines lLines + 3, "End Sub"
-
End With
-
Exit For
-
End If
-
Next s
-
End Sub
Obviously, you have some translation to do.
But, I have had a lot of trouble trying to do the stuff you have already done. Can you outline the steps to creating the Addin with C# 2005? I want to add a dialog box. I could do it with VB6, but am stuck with .Net.
thanx frnd
its working, just need little translation.
As far as creating addin in C# is concerned,
there are two ways
1. VSTO addin
2. Shared addin
VSTO is future but still little still not support all office applications like access.
main steps for creating shared addin
1 .In the New Project dialog box, expand Other Projects under Project Types, select Extensibility Projects, and then select the Shared Add-in template.
2 . Type xyz as the name of the add-in and then click OK.
3. When the Extensibility Wizard appears, follow these steps:
4. select Create an Add-in using Visual C#, and then click Next.
5. select the any host applications, and then click Next:
Automatically it wil generate a lot of code for u.
The class of interest is Connect class
add following reference in connect class
using Core = Microsoft.Office.Core;
using Excel = Microsoft.Office.Interop.Excel;
using System.Windows.Forms;
I have just given here is just abstract description
these are two links to gud one to start with
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q302901
http://msdn2.microsoft.com/en-us/library/aa663367.aspx
just reply if there is any problem
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Jaime Rios |
last post by:
Hi,
I created a COM AddIn for Word that performs the functions
that it needs to, but I needed to add the ability for the
toolbar created by the COM AddIn to remember it's last
position and...
|
by: DC Gringo |
last post by:
I have a simple button that should open another window and export a datagrid
to an Excel file. I'm getting: "Name 'window' is not declared."
What do I need to declare or import?
<INPUT...
|
by: elziko |
last post by:
I'm using late binding (I must) to automate Excel.
My code opens Excel after createing and poulating some sheets. My problem is
that when the user finally decides to close Excel its process is...
|
by: maitrepoy |
last post by:
Hello
I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003.
This addin consists in adding 2 new Buttons in the "File" Menu of office....
|
by: maitrepoy |
last post by:
hello
I have to create a small addin which works on Powerpoint, Word, Outlook, and Excel on Office 2000, XP, and 2003.
This addin consists in adding 2 new Buttons in the "File" Menu of office....
|
by: Nick Dreyer |
last post by:
Is it possible to see public class variables of a COM addin in Excel 97 VBA?
I have successfully created the (Visual Basic 2003 .NET) COM
and referenced it in an Excel 97 VBA project. The VBA...
|
by: Frank M. Walter |
last post by:
Hello,
I have made an small AddIn with udf for excel 2003.
I use vs2003.
The point of view is the function __T()
I call it in excel sheet writing =__T()
I am not able to set a value to a...
|
by: Omer |
last post by:
I am trying to create a shared addin using visual studio 2005 with the
following code. It is working only in Power Point Appliction and not loading
in Excel and Word I used the Visual Studio Wizard...
|
by: =?Utf-8?B?THluZXJz?= |
last post by:
Hello All,
We have a VB.NET application writen using VS 2003. This application apens an
excel file from a vendor, reads the data and performs whatever functions it
needs. We recently upgraded our...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: aa123db |
last post by:
Variable and constants
Use var or let for variables and const fror constants.
Var foo ='bar';
Let foo ='bar';const baz ='bar';
Functions
function $name$ ($parameters$) {
}
...
|
by: ryjfgjl |
last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
|
by: Hystou |
last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers,...
| | |