none
Adjusting line weight for all shapes in a document RRS feed

  • Question

  • I have a word document in which are many shapes. These shapes contain several thick lines (usually width 0/0.05pt/0.1pt).

    These thick lines cause problem so I'd like to set them to at least 0,25.

    It is no use setting these line weights by hand 'cause there are too many (e.g. background grids at diagrams) so I'd like to find some tool/VBA macro to do it.

    I am thinking about something like that:

    for each shape in active document

       for each line/rectangle/oval/etc

          if line weight < 0.25 then set to 0.25

    Thanx in andvance!





    • Edited by Jazoja2 Thursday, July 18, 2013 10:53 AM
    Thursday, July 18, 2013 10:46 AM

Answers

  • Hi Jazoja2,

    According your description, you want to edit the border of shapes which line weight <0.25.I write a simple sample for you.

    Sub SetShapeStyle()
    
    Debug.Print ActiveDocument.InlineShapes.Count
    
    Debug.Print ActiveDocument.Shapes.Count
    
    
    For i = 1 To ActiveDocument.InlineShapes.Count
    
    
    ActiveDocument.InlineShapes(i).Borders(wdBorderBottom) = True
    
    ActiveDocument.InlineShapes(i).Borders(wdBorderLeft) = True
    
    ActiveDocument.InlineShapes(i).Borders(wdBorderRight) = True
    
    ActiveDocument.InlineShapes(i).Borders(wdBorderTop) = True
    
    
    If ActiveDocument.InlineShapes(i).Borders(wdBorderBottom).LineWidth < wdLineWidth025pt Then
    
        With ActiveDocument.InlineShapes(i).Borders(wdBorderBottom)
    
            .LineStyle = wdLineStyleDot
    
            .LineWidth = wdLineWidth025pt
    
            .Color = wdColorRed
    
        End With
    
    End If
    
    
    If ActiveDocument.InlineShapes(i).Borders(wdBorderLeft).LineWidth < wdLineWidth025pt Then
    
        With ActiveDocument.InlineShapes(i).Borders(wdBorderLeft)
    
            .LineStyle = wdLineStyleDot
    
            .LineWidth = wdLineWidth025pt
    
            .Color = wdColorRed
    
        End With
    
    End If
    
    
    If ActiveDocument.InlineShapes(i).Borders(wdBorderRight).LineWidth < wdLineWidth025pt Then
    
        With ActiveDocument.InlineShapes(i).Borders(wdBorderRight)
    
            .LineStyle = wdLineStyleDot
    
            .LineWidth = wdLineWidth025pt
    
            .Color = wdColorRed
    
        End With
    
    End If
    
    
    If ActiveDocument.InlineShapes(i).Borders(wdBorderTop).LineWidth < wdLineWidth025pt Then
    
        With ActiveDocument.InlineShapes(i).Borders(wdBorderTop)
    
            .LineStyle = wdLineStyleDot
    
            .LineWidth = wdLineWidth025pt
    
            .Color = wdColorRed
    
        End With
    
    End If
    
    
    Next i
    
    End Sub
    

    If you want to learn more about vba you can read the article below.

    Getting Started with VBA in Office 2010

    http://msdn.microsoft.com/en-us/library/office/ee814735(v=office.14).aspx

    Thursday, July 18, 2013 4:38 PM