rdg_dawg
07-08-2004, 12:41 PM
I am having a problem with trying to find a way to change the (text/caption) property of a button I created in Excel within my code. Imports Microsoft.Office.Core
Public Class Form1
Inherits System.Windows.Forms.Form
Dim thisApplication As New Excel.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim wb As Excel.Workbook = thisApplication.Workbooks.Open("C:\training.xls")
Dim sh As Excel.Worksheet
Dim myPicture As Excel.Shapes
'insert the picture
sh.Shapes.AddPicture("C:\Documents and Settings\RGoudelock\My Documents\My Pictures\UCB.gif", _
Office.MsoTriState.msoTrue, Office.MsoTriState.msoTrue, 0, 0, 120, 40)
sh.Shapes.AddFormControl(Excel.XlFormControl.xlButtonControl, 0, 50, 100, 30)
'Save all the workbooks in the application
For Each wb In thisApplication.Workbooks
wb.Save()
Next wb
wb.Close()
thisApplication.Quit()
wb = Nothing
sh = Nothing
GC.Collect()
End Sub
Public Class Form1
Inherits System.Windows.Forms.Form
Dim thisApplication As New Excel.Application
Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) _
Handles Button1.Click
Dim wb As Excel.Workbook = thisApplication.Workbooks.Open("C:\training.xls")
Dim sh As Excel.Worksheet
Dim myPicture As Excel.Shapes
'insert the picture
sh.Shapes.AddPicture("C:\Documents and Settings\RGoudelock\My Documents\My Pictures\UCB.gif", _
Office.MsoTriState.msoTrue, Office.MsoTriState.msoTrue, 0, 0, 120, 40)
sh.Shapes.AddFormControl(Excel.XlFormControl.xlButtonControl, 0, 50, 100, 30)
'Save all the workbooks in the application
For Each wb In thisApplication.Workbooks
wb.Save()
Next wb
wb.Close()
thisApplication.Quit()
wb = Nothing
sh = Nothing
GC.Collect()
End Sub