Adding


Shapes.AddCanvasRemoved in 2007
Shapes.AddCalloutCreates a borderless line callout shape
Shapes.AddConnectorCreates a chart. Charts > VBA
Shapes.AddCurveCreates a connector shape
Shapes.AddFormControlCreates a bezier curve
Shapes.AddLabelCreates a Form Control. Macros > Worksheet Controls
Shapes.AddLineCreates a line shape
Shapes.AddOLEObjectCreates an ActiveX control Macros > Worksheet Controls
Shapes.AddPictureReplaced with AddPicture2
Shapes.AddPicture2Creates a picture from an existing file
Shapes.AddPolylineCreates an open polyline or closed polyline shape
Shapes.AddShapeCreates an Autoshape.
Shapes.AddTextboxCreates a textbox shape
Shapes.AddTextEffectCreates a WordArt

Shapes.AddPicture2

Adds a picture to a worksheet.
The Shapes.AddPicture method does not have the Compress argument.

Dim oWsh as Excel.Worksheet 
Dim oShape As Excel.Shape
Set oWsh = Application.ActiveSheet
Set oShape = oWsh.Shapes.AddPicture2(FileName:="C:\temp\image.bmp, _
                                     LinkToFile:=msoTriState.msoFalse, _
                                     SaveWithDocument:=msoTriState.msoTrue, _
                                     Left:=80, _
                                     Top:=80, _
                                     Width:=80, _
                                     Height:=80, _
                                     Compress:=msoPictureCompress.msoPictureCompressFalse)

FileName - The full path of the picture or graphic to insert
LinkToFile - Indicates whether the picture is linked or not
SaveWithDocument - Indicates whether the picture is saved in the worksheet (must be true in VBA. If set to false you set a "the specified value is out of range" error)
Left - The position of the left edge relative to the active cell (in points)
Top - The position of the top edge relative to the active cell (in points)
Width - The width of the picture (in points)
Height - The height of the picture (in points)
Compress - Determines whether the picture should be compressed when inserted



Shapes.AddShape

Dim oWsh as Excel.Worksheet 
Dim oShape As Excel.Shape
Set oWsh = Application.ActiveSheet
Set oShape = oWsh.Shapes.AddShape(Type:=msoAutoShapeType.msoShapeMoon, _
                                  Left:=20, _
                                  Top:=20, _
                                  Width:=20, _
                                  Height:=20)

Type -
Left - The position of the left edge relative to the active cell (in points)
Top - The position of the top edge relative to the active cell (in points)
Width -
Height -


Set oShape = oWsh.Shapes.AddShape(msoShape16pointStar, _ 
    ActiveCell.Left, ActiveCell.Top, 80, 27)



Shapes.AddTextBox

ActiveSheet.Shapes.AddTextBox(Orientation:=msoTextOrientation.msoTextOrientationHorizontal, _ 
                              Left:=
                              Top:=
                              Width:=
                              Height:=)

Orientation -
Left - The position of the left edge relative to the active cell (in points)
Top - The position of the top edge relative to the active cell (in points)
Width -
Height -


Shapes.AddTextBox(msoTextOrientationHorizontal, Selection.Left, Selection.Top, 20, 20) 
Shapes.AddTextBox(msoTextOrientationHorizontal, Range("B2").Left, Range("B2").Top, 20, 20)


Shapes.AddTextEffect

Adds WordArt

ActiveSheet.Shapes.AddTextEffect(PresetTextEffect:=, _ 
                                 Text:=, _
                                 FontName:=, _
                                 FontSize:=, _
                                 FontBold:=, _
                                 FontItalic:=, _
                                 Left:=, _
                                 Top:=).Select

PresetTextEffect -
Text -
FontName -
FontSize -
FontBold -
FontItalic -
Left -
Top -


Pictures.Insert (depreciated)

In Excel 2007 this method inserts the picture as an embedded object
In Excel 2010 and later this method inserts the picture as a link (be warned)
This method is not displayed in the intellisense and is only available for backwards compatibility

Dim oWsh As Excel.Worksheet 
Dim oPicture As Excel.Picture
Set oPicture = oWsh.Pictures.Insert(Filename:="C:\temp\picture.png")

oPicture.Width =
oPicture.Height =
oPicture.Left =
oPicture.Top =
oPicture.Placement = xlMoveAndSize
oPicture.PrintObject

© 2024 Better Solutions Limited. All Rights Reserved. © 2024 Better Solutions Limited TopPrevNext