excel with vb.net

J

jakekeke

Dear all,

I would like to use excel and vb.net to create a report(xml) generator,
however, i wouldnt find any source for making shapes(button,label) from
vb.net to initial excel
what i want to know is how can i get the actionlistener of a button,
which the coding is made in VB.Net but the button is added on a
spreadsheet
i think i have store the object reference of that button
but using onAction is not possible since i want control the
actionlistenre in my Vb.net, is it possible??

Thank and regards,
Jake
 
C

Cor Ligthert

Jake,

In my opinion do you have to decide where your action (your button) is. It
is either in a windowforms and than you can use VBNet or it is on your
spreadsheet and than you can use Excel programming.

Just my opinion.

Cor
 
C

Carlos J. Quintero [.NET MVP]

Hi,

I don¡¦t know the exact answer to that question, but those kinds of things
seem a good candidate to use Visual Studio Tools for Office (VSTO). VSTO is
an add-on for VS.NET 2003 which allows you to build Office solutions using
..NET instead of VBA. See:

http://msdn.microsoft.com/office/understanding/vsto/

--

Best regards,

Carlos J. Quintero

MZ-Tools: Productivity add-ins for Visual Studio .NET, VB6, VB5 and VBA
You can code, design and document much faster.
Free resources for add-in developers:
http://www.mztools.com
 
J

jakekeke

hi,

thx u 2 guys reply
my code will based on VB.net(VS.net) only
however, i need generate so buttons on spreadsheet to make it function
well
if i use the method .onaction.....it seem i should assign a marco on
it....
doesnt it?
can i do all my stuff on vb.net only?
ie, all the action handler can only be found on vb.net

thx and regard,
Jake
 
J

jakekeke

to explain more clearly
i post my coding here

Private Sub ThisWorkbook_Open() Handles ThisWorkbook.Open

' Visual Basic
Dim str As String
str = "About Visual Basic"
Dim mySheet As Excel.Worksheet
Dim myRange As Excel.Range

mySheet = _
CType(Me.ThisApplication.Sheets.Item(1), _
Excel.Worksheet)

Dim sel As Excel.Button
sel = _
CType(mySheet.Buttons.Add(143.25, 83.25, 97.5, 27), _
Excel.Button)
MsgBox(11)
MsgBox(sel.Text)
sel.Text = "test"
MsgBox(sel.Text)

'do sth here!!!!

MsgBox(22)

CType(mySheet.Cells.Item(2, 2), Excel.Range).Value _
= "Hello From"
CType(mySheet.Cells.Item(3, 2), Excel.Range).Value _
= "About Visual Basic"
myRange = mySheet.Range("B2:B3")
myRange.Font.ColorIndex = 3
myRange.Font.Bold = True
myRange.Font.Size = 18
opened = True
End Sub

in the comment "do sth here!!!!"
can i add some statement to control action of button on the
spreadsheet??
just like onAction in macro...........

thx
 

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