下面的代码是在Microsoft Word 97-2003中创建的(不是我,并保存为* .dotm),当默认情况下"插入形状/行"是黑色的。用作具有特定封面,标题,大纲样式等的过程模板。当* .doc文件保存到* .docx时," SignoffLine
"宏被激活,插入的线条颜色为蓝色(插入形状/线条的MS Word 2010默认值?)。
我可以更改每个文档的默认颜色,我可以通过Normal.dotm
更改它,但是想要编辑下面的宏,这样插入的行总是黑色的。
Sub SignoffLine()
On Error GoTo endthis
i = Selection.Information(wdVerticalPositionRelativeToPage)
Set oFFline = ActiveDocument.Shapes.AddLine(554, i + 12, 524, i + 12).Line
With oFFline.Line
.Weight = 0.75
End With
oFFline.Name = "hline" & idi
idi = idi + 1
endthis:
End Sub
答案 0 :(得分:0)
这很简单......您需要将oFFline
对象定义为Shape
,然后将其属性设置如下:
Sub SignoffLine()
Dim oFFline As Shape
Dim i As Integer
On Error GoTo endthis
i = Selection.Information(wdVerticalPositionRelativeToPage)
Set oFFline = ActiveDocument.Shapes.AddLine(554, i + 12, 524, i + 12)
With oFFline.Line
.Weight = 0.75
'set black color
.ForeColor.RGB = RGB(0, 0, 0)
End With
oFFline.Name = "hline" & idi
idi = idi + 1
endthis:
Set oFFline = Nothing
End Sub
有关详细信息,请参阅:Shape Object (Word)和RGB