I recorded this macro in Excel 2003 and it works fine:
Two question.
1. Does anyone have any idea why this code would not work in Excel 2007? I don't have excel 2007 so I can't try recording it on there and comparing. I found out it doesn't work from a user.
2. Is there a better way to write this code? Basically, I want to hit the macro and a line appears in a specific location on the sheet for the user.
Thanks, Dan
Code:
Sub Vertical()
ActiveSheet.Unprotect
ActiveSheet.Shapes.AddLine(597.75, 57, 597.75, 600#).Select
Selection.ShapeRange.Fill.Transparency = 0#
Selection.ShapeRange.Line.Weight = 0.75
Selection.ShapeRange.Line.DashStyle = msoLineSolid
Selection.ShapeRange.Line.Style = msoLineSingle
Selection.ShapeRange.Line.Transparency = 0#
Selection.ShapeRange.Line.Visible = msoTrue
Selection.ShapeRange.Line.ForeColor.SchemeColor = 10
Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
Selection.ShapeRange.Line.BeginArrowheadLength = msoArrowheadLengthMedium
Selection.ShapeRange.Line.BeginArrowheadWidth = msoArrowheadWidthMedium
Selection.ShapeRange.Line.BeginArrowheadStyle = msoArrowheadNone
Selection.ShapeRange.Line.EndArrowheadLength = msoArrowheadLengthMedium
Selection.ShapeRange.Line.EndArrowheadWidth = msoArrowheadWidthMedium
Selection.ShapeRange.Line.EndArrowheadStyle = msoArrowheadNone
Selection.ShapeRange.LockAspectRatio = msoFalse
Selection.ShapeRange.Height = 580
Selection.ShapeRange.Width = 0#
Selection.ShapeRange.Rotation = 0#
Selection.Locked = False
ActiveSheet.Protect DrawingObjects:=True, Contents:=True, Scenarios:=True
End Sub
Two question.
1. Does anyone have any idea why this code would not work in Excel 2007? I don't have excel 2007 so I can't try recording it on there and comparing. I found out it doesn't work from a user.
2. Is there a better way to write this code? Basically, I want to hit the macro and a line appears in a specific location on the sheet for the user.
Thanks, Dan