1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51
|
Public Class ThisWorkbook
Private Sub ThisWorkbook_Startup(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Startup
Dim rng As Excel.Range = Nothing
Dim feuille As Excel.Worksheet = Me.Worksheets(1)
rng = feuille.Range("a1:a1")
rng.Value = "this is my string"
'Ajout de 3 shapes
' 1er shape
Dim shp As Excel.Shape = Nothing
shp = feuille.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationDownward, 50, 50, 100, 100)
shp.Fill.ForeColor.RGB = RGB(100, 200, 21)
shp.Name = "textbox1"
shp.TextFrame.Characters.Text = "Jahid1"
shp.TextFrame.Characters.Font.Size = 20
shp.TextFrame.Characters.Font.Name = "Times New Roman"
shp.TextFrame.Characters.Font.Color = ColorTranslator.ToOle(Color.Red)
'2eme shape
shp = feuille.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 60, 60, 200, 200)
shp.Name = "textbox2"
shp.Fill.ForeColor.RGB = RGB(200, 200, 21)
shp.TextFrame.Characters.Text = "Omar textbox1"
shp.TextFrame.Characters.Font.Size = 20
shp.TextFrame.Characters.Font.Name = "Arial"
shp.TextFrame.Characters.Font.Color = ColorTranslator.ToOle(Color.Blue)
' 3eme shape
shp = feuille.Shapes.AddTextbox(Microsoft.Office.Core.MsoTextOrientation.msoTextOrientationHorizontal, 80, 80, 200, 200)
shp.Name = "textbox3"
'access and define prop with for each ........statement
For Each myShp As Excel.Shape In feuille.Shapes
If myShp.Name = "textbox3" Then
shp.Fill.ForeColor.RGB = RGB(140, 120, 240)
shp.TextFrame.Characters.Text = "Changed " & rng.Value
shp.TextFrame.Characters.Font.Size = 18
shp.TextFrame.Characters.Font.Name = "Arial"
shp.TextFrame.Characters.Font.Color = ColorTranslator.ToOle(Color.Gold)
End If
Next
End Sub
Private Sub ThisWorkbook_Shutdown(ByVal sender As Object, ByVal e As System.EventArgs) Handles Me.Shutdown
End Sub
End Class |
Partager