View Single Post
  #3   Report Post  
Posted to microsoft.public.excel.programming
John Coleman John Coleman is offline
external usenet poster
 
Posts: 274
Default Error when inserting AutoShape ????????

Try this:

Sub InsertFlash01()
'
'
Dim myShape As Shape
Set myShape = ActiveSheet.Shapes.AddShape(msoShapeExplosion2,
407.25, 162#, 525#, 409.5)
myShape.Fill.ForeColor.SchemeColor = 13
myShape.Fill.Visible = msoTrue
myShape.Fill.Solid
myShape.TextFrame.Characters.Text = "THERE ARE NO NEW Gams
DOCUMENTS TO BE SHOWN "
With myShape.TextFrame
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext
.Orientation = msoTextOrientationHorizontal
.AutoSize = False
End With
With myShape.TextFrame.Characters.Font
.Name = "BMWTypeRegular"
.FontStyle = "Bold"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("A1").Select
End Sub

All sorts of wierd implicit type-casting was going on with the
Selection - replacing it with a shape variable revealed that you were
not using the shape object-heirarchy correctly. I hope thisworks f0r
you. Remember to remove stray line-breaks from google.

-John Coleman
Les Stout wrote:
Hi, i have the code below that works perfectly in my Personal VBA
project, but the will not work in another VBA Project and i get a
compile error msg "Expected function or variable"
and then highlites "selection" of the second line ??? Can anybody help,
me out of my misery please ??

Sub InsertFlash01()
'
'
ActiveSheet.Shapes.AddShape(msoShapeExplosion2, 407.25, 162#, 525#,
409.5) _
.Select
Selection.ShapeRange.Fill.ForeColor.SchemeColor = 13
Selection.ShapeRange.Fill.Visible = msoTrue
Selection.ShapeRange.Fill.Solid
Selection.Characters.Text = "THERE ARE NO NEW Gams DOCUMENTS TO BE
SHOWN"
With Selection
.HorizontalAlignment = xlCenter
.VerticalAlignment = xlCenter
.ReadingOrder = xlContext
.Orientation = xlHorizontal
.AutoSize = False
End With
With Selection.Font
.Name = "BMWTypeRegular"
.FontStyle = "Bold"
.Size = 20
.Strikethrough = False
.Superscript = False
.Subscript = False
.OutlineFont = False
.Shadow = False
.Underline = xlUnderlineStyleNone
.ColorIndex = xlAutomatic
End With
Range("A1").Select
End Sub




Les Stout

*** Sent via Developersdex http://www.developersdex.com ***