Code Crashes in 2007, I can't seem to solve this!

XLXRider

Board Regular
Joined
Jul 31, 2004
Messages
180
Hi, Excellers!

This code crashes in Excel 2007, but runs fine in 2003. I know where it crashes, I just don't know why. Any help is most appreciated.

Code:
Sub Instructions()
'
' Instructions Macro
' Macro by The Great and Powerful Oz

'Assigned to the "Help" Button
     Application.ScreenUpdating = False
    ActiveSheet.Shapes.AddShape(msoShapeRectangle, 89, 30, 465, 240).Name = "Instructions"
    ActiveSheet.Shapes("Instructions").Select
    Selection.OnAction = "InstructionsGone"
    Selection.ShapeRange.Fill.Visible = msoTrue
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.ForeColor.SchemeColor = 26
    Selection.ShapeRange.Fill.Transparency = 0#
    Selection.ShapeRange.Line.Weight = 5
    Selection.ShapeRange.Line.DashStyle = msoLineSolid
    Selection.ShapeRange.Line.Style = msoLineThinThin
    Selection.ShapeRange.Line.Transparency = 0#
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.ForeColor.SchemeColor = 12
    Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
    
    Selection.Characters.Text = _
        "  " & Chr(10) & "   How to use this file:" & Chr(10) & "" & Chr(10) & "  First, make a copy of Master.  Work off the copy, not Master itself." & Chr(10) & Chr(10) & "  Next, put the individual's name in "
    Selection.Characters(203).Insert String:= _
        "the very top cell - M1 - that contains the text ""Master.""" & Chr(10) & "  Cell M1, and the sheet's tab is automatically named.  Any other cell, and it's not." & Chr(10) & Chr(10) & "  Put the "
    Selection.Characters(401).Insert String:= _
        "individual's annual Vacation Days in the colored cell indicated by ""Days Available.""" & Chr(10) & Chr(10) & "  To indicate a Full or Half-Day Vacation,"
Etcetera...

It runs down to "Selection.Characters.Text =" but when it gets to the next line, "Selection.Characters(203).Insert String:=" it crashes.

Advice from all gurus welcome!

TIA,
XLXRider
 

Excel Facts

Save Often
If you start asking yourself if now is a good time to save your Excel workbook, the answer is Yes
Why do you keep trying to insert a new string? Why not place all the text into the shape at the same time, using characters.text?

Also, you have "selection." a millions times. Why not use a "with"

Code:
with activesheet.shapes("Instructions").shaperange
     .fill.visible = ...
     .line.weight = ...
end with
[code/]
 
Upvote 0
Hmmmm... I will give that stuff a try. thanks, pplstuff, for the answer. I'll post later if I get it to work or not.

Regards,
XLXRider
 
Upvote 0

Forum statistics

Threads
1,224,606
Messages
6,179,862
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top