• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 1336
  • Last Modified:

Macro Doesn't Work in Word 2007

User has a macro that inserts and formats a text box in a Word document.  The Macro works great in Word 2003 and it works in Word 2007 when in compatibility mode.  When the user converts the document to the new .docm format the macro stops working.  The macro errors out with a Run-Time error '5917' - this object does not support attached text.

It appears as though the script fails because there are multiple text boxes in the document.  The macro will add the text box but the formatting fails.  Looks like the macro may be trying to format one of the other text boxes.  If I delete all the text boxes from the document then the macro runs just fine.  Anyone have any ideas?  Thanks!
Sub Paste()
'
' Paste Macro
' Macro recorded 8/1/2008 by userid
'
    Selection.ShapeRange.IncrementLeft 290.45
    Selection.ShapeRange.IncrementTop 3.25
    Selection.ShapeRange.Fill.Visible = msoFalse
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.Transparency = 0#
    Selection.ShapeRange.Line.Weight = 1.5
    Selection.ShapeRange.Line.DashStyle = msoLineSolid
    Selection.ShapeRange.Line.Style = msoLineSingle
    Selection.ShapeRange.Line.Transparency = 0#
    Selection.ShapeRange.Line.Visible = msoTrue
    Selection.ShapeRange.Line.ForeColor.RGB = RGB(0, 0, 0)
    Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
    Selection.ShapeRange.LockAspectRatio = msoTrue
    Selection.ShapeRange.Rotation = 0#
    Selection.ShapeRange.PictureFormat.Brightness = 0.5
    Selection.ShapeRange.PictureFormat.Contrast = 0.5
    Selection.ShapeRange.PictureFormat.ColorType = msoPictureAutomatic
    Selection.ShapeRange.PictureFormat.CropLeft = 0#
    Selection.ShapeRange.PictureFormat.CropRight = 0#
    Selection.ShapeRange.PictureFormat.CropTop = 0#
    Selection.ShapeRange.PictureFormat.CropBottom = 0#
    Selection.ShapeRange.Left = 318.95
    Selection.ShapeRange.Top = 44.6
    Selection.ShapeRange.RelativeHorizontalPosition = _
        wdRelativeHorizontalPositionColumn
    Selection.ShapeRange.RelativeVerticalPosition = _
        wdRelativeVerticalPositionParagraph
    Selection.ShapeRange.Left = InchesToPoints(3.93)
    Selection.ShapeRange.Top = InchesToPoints(0.12)
    Selection.ShapeRange.LockAnchor = False
    Selection.ShapeRange.LayoutInCell = True
    Selection.ShapeRange.WrapFormat.AllowOverlap = True
    Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
    Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
    Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
    Selection.ShapeRange.WrapFormat.Type = wdWrapTight
End Sub
Sub CallOut()
'
' CallOut Macro
' Macro recorded 8/1/2008 by userid
'
    ActiveDocument.Shapes.AddTextbox(msoTextOrientationHorizontal, 251.6, _
        84.95, 16.2, 17#).Select
    Selection.ShapeRange.TextFrame.TextRange.Select
    Selection.Collapse
    With Selection.ParagraphFormat
        .Borders(wdBorderLeft).LineStyle = wdLineStyleNone
        .Borders(wdBorderRight).LineStyle = wdLineStyleNone
        .Borders(wdBorderTop).LineStyle = wdLineStyleNone
        .Borders(wdBorderBottom).LineStyle = wdLineStyleNone
        With .Borders
            .DistanceFromTop = 1
            .DistanceFromLeft = 4
            .DistanceFromBottom = 1
            .DistanceFromRight = 4
            .Shadow = False
        End With
    End With
    With Options
        .DefaultBorderLineStyle = wdLineStyleSingle
        .DefaultBorderLineWidth = wdLineWidth050pt
        .DefaultBorderColor = wdColorAutomatic
    End With
    Selection.ShapeRange.Fill.Visible = msoTrue
    Selection.ShapeRange.Fill.Solid
    Selection.ShapeRange.Fill.ForeColor.RGB = RGB(255, 255, 255)
    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.RGB = RGB(0, 0, 0)
    Selection.ShapeRange.Line.BackColor.RGB = RGB(255, 255, 255)
    Selection.ShapeRange.LockAspectRatio = msoFalse
    Selection.ShapeRange.Height = 17.3
    Selection.ShapeRange.Width = 16.55
    Selection.ShapeRange.Left = 251.25
    Selection.ShapeRange.Top = 84.95
    Selection.ShapeRange.TextFrame.MarginLeft = 0.72
    Selection.ShapeRange.TextFrame.MarginRight = 0.72
    Selection.ShapeRange.TextFrame.MarginTop = 0.72
    Selection.ShapeRange.TextFrame.MarginBottom = 0.72
    Selection.ShapeRange.RelativeHorizontalPosition = _
        wdRelativeHorizontalPositionColumn
    Selection.ShapeRange.RelativeVerticalPosition = _
        wdRelativeVerticalPositionParagraph
    Selection.ShapeRange.Left = InchesToPoints(2.99)
    Selection.ShapeRange.Top = InchesToPoints(0.68)
    Selection.ShapeRange.LockAnchor = False
    Selection.ShapeRange.LayoutInCell = True
    Selection.ShapeRange.WrapFormat.AllowOverlap = True
    Selection.ShapeRange.WrapFormat.Side = wdWrapBoth
    Selection.ShapeRange.WrapFormat.DistanceTop = InchesToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceBottom = InchesToPoints(0)
    Selection.ShapeRange.WrapFormat.DistanceLeft = InchesToPoints(0.13)
    Selection.ShapeRange.WrapFormat.DistanceRight = InchesToPoints(0.13)
    Selection.ShapeRange.WrapFormat.Type = 3
    Selection.ShapeRange.ZOrder 4
    Selection.ShapeRange.TextFrame.AutoSize = False
    Selection.ShapeRange.TextFrame.WordWrap = True
    Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
    Selection.Font.Bold = wdToggle
    Selection.TypeText Text:="A"
    Selection.ShapeRange.Select
    Selection.ShapeRange.ScaleWidth 0.9, msoFalse, msoScaleFromTopLeft
    Selection.ShapeRange.ScaleHeight 0.91, msoFalse, msoScaleFromTopLeft
End Sub

Open in new window

0
FAFitzgerald
Asked:
FAFitzgerald
  • 3
  • 2
1 Solution
 
Joanne M. OrzechManager, Document Services CenterCommented:
Probably the easiest thing to do is re-record the macro in 2007.
0
 
FAFitzgeraldAuthor Commented:
Yeah we tried that but it still errors out.
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Well, I've tried it with text boxes, autoshapes, and images, and it doesn't recognize any of them.  You say she has "text" boxes inserted?  And we're sure they're plain old text boxes?
0
Ultimate Tool Kit for Technology Solution Provider

Broken down into practical pointers and step-by-step instructions, the IT Service Excellence Tool Kit delivers expert advice for technology solution providers. Get your free copy now.

 
FAFitzgeraldAuthor Commented:
Yes they are plain old text boxes.  I can duplicate the error by adding several plain old text boxes to a new document and then by running the macro.  It will run a time or two and then it gets the same error.  I saved the newly created document in the older format and it works for a while but then fails with the same error.  Stange.  Went back to the original Word 2003 doc and it's working fine every time I run the macro.  STRANGE!
0
 
Joanne M. OrzechManager, Document Services CenterCommented:
Sorry - I can't seem to get it to work in either version.
0
 
sceserCommented:
Friends. I have a simular situation where I and formating a booklet from VFP in word. The text is placed in various tables for printing. Word 2007 broke the VB somewhere in the setwidth / setpointsto- formating. I needed to reload 2003 to run the process after spending hours trying to fix.
Please keep trying to find the solution
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Free Tool: Port Scanner

Check which ports are open to the outside world. Helps make sure that your firewall rules are working as intended.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now