none
Shape color RRS feed

  • Question

  • I have the following macro that draws a line in a document. With the document saved as a .doc and I run the macro the line is BLACK. We are starting to save our documents as .docx files. When we save a document as a .docx file and run the following macro the line is now BLUE. How do I revise my macro to default back to BLACK?

    Sub AddRevisionBar()
    On Error GoTo endthis
    For Each aVar In ActiveDocument.Variables
        If aVar.Name = "idx" Then
            num = aVar.Index
            Exit For
        End If
    Next aVar

    If num = 0 Then
        ActiveDocument.Variables.Add Name:="idx", Value:=0
    End If
        idx = ActiveDocument.Variables("idx").Value + 1
        i = Selection.Information(wdVerticalPositionRelativeToPage)
        j = InchesToPoints(InputBox("BAR LENGTH {In Inches}:"))
        ActiveDocument.Shapes.AddLine(562, i, 562, j + i).Name = "vline" & idx
        ActiveDocument.Variables("idx").Value = idx
    endthis:
    Set aVar = Nothing
    End Sub

    Thursday, February 5, 2015 7:58 PM

Answers

  • Change

        ActiveDocument.Shapes.AddLine(562, i, 562, j + i).Name = "vline" & idx

    to

        With ActiveDocument.Shapes.AddLine(562, i, 562, j + i)
            .Name = "vline" & idx
            .Line.ForeColor.RGB = vbBlack
        End With


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, February 5, 2015 8:11 PM
  • Thanks that worked.
    • Marked as answer by fuzzhead58 Thursday, February 5, 2015 8:38 PM
    Thursday, February 5, 2015 8:38 PM

All replies

  • Change

        ActiveDocument.Shapes.AddLine(562, i, 562, j + i).Name = "vline" & idx

    to

        With ActiveDocument.Shapes.AddLine(562, i, 562, j + i)
            .Name = "vline" & idx
            .Line.ForeColor.RGB = vbBlack
        End With


    Regards, Hans Vogelaar (http://www.eileenslounge.com)

    Thursday, February 5, 2015 8:11 PM
  • Thanks that worked.
    • Marked as answer by fuzzhead58 Thursday, February 5, 2015 8:38 PM
    Thursday, February 5, 2015 8:38 PM