Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Macro Doesn't Work in Word 2007

Posted on 2009-04-30
6
Medium Priority
?
1,281 Views
Last Modified: 2013-11-10
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
Comment
Question by:FAFitzgerald
  • 3
  • 2
6 Comments
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 24272791
Probably the easiest thing to do is re-record the macro in 2007.
0
 

Author Comment

by:FAFitzgerald
ID: 24273211
Yeah we tried that but it still errors out.
0
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 24273432
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
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

Accepted Solution

by:
FAFitzgerald earned 0 total points
ID: 24275125
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
 
LVL 37

Expert Comment

by:Joanne M. Orzech
ID: 24279492
Sorry - I can't seem to get it to work in either version.
0
 

Expert Comment

by:sceser
ID: 27655681
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

Featured Post

Free Tool: SSL Checker

Scans your site and returns information about your SSL implementation and certificate. Helpful for debugging and validating your SSL configuration.

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.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Microsoft Office Picture Manager was included in Office 2003, 2007, and 2010, but not in Office 2013. Users had hopes that it would be in Office 2016/Office 365, but it is not. Fortunately, the same zero-cost technique that works to install it with …
In this post, we will learn to set up the Group Naming policy and will see how it is going to impact the Display Name and the Email addresses of the Group.
Simple Linear Regression
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question