宏命令语句
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
Private Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long) Option Explicit
Sub Macro1()
Dim lineProgramRange As Range '单行程序代码范围
Dim selRge As Range
Dim i As Long
Dim num As Long
' Macro1 Macro
' 宏在2013-4-17 由许长安录制
Dim paraNum
', i As Integer
paraNum = ActiveDocument.Paragraphs.Count
'Selection.MoveDown Unit:=wdLine, Count:=1
'Set selRge = Selection.Range
MsgBox "The selection is on page " & _
rmation(wdActiveEndPageNumber) & "; Column " _
& rmation(wdFirstCharacterColumnNumber) & _
"; Line " _
& rmation(wdFirstCharacterLineNumber) & _
"; 总行数: " _
& ActiveDocument.Paragraphs.Count
'num = rmation(wdFirstCharacterLineNumber)
Dim myColor As Long
myColor = ActiveDocument.Background.Fill.ForeColor.RGB
MsgBox GetColor(myColor)
For num = rmation(wdFirstCharacterLineNumber) To paraNum Selection.MoveDown Unit:=wdLine, Count:=1
Selection.HomeKey Unit:=wdLine '光标回到行首Selection.EndKey Unit:=wdLine, Extend:=wdExtend '选中整行
'Selection.MoveDown Unit:=wdLine, Count:=1, Extend:=wdExtend
Options.DefaultHighlightColorIndex = wdRed
Selection.Range.HighlightColorIndex = wdRed
Sleep 100
'Selection.MoveUp Unit:=wdLine, Count:=1, Extend:=wdExtend
Options.DefaultHighlightColorIndex = wdNoHighlight
Selection.Range.HighlightColorIndex = wdNoHighlight
MsgBox "; 总行数" & num
'得到当前选中行并设置颜色为蓝色
'Set lineProgramRange = selRge.Paragraphs(i).Range
'Paragraphs(rmation(wdFirstCharacterLineNumber)).Range
'Selection.Font.ColorIndex = wdBlue
'lineProgramRange.Font.ColorIndex = wdBlue
' selRge.Paragraphs(nLineNum).Range.InsertBefore (sLineNum)
Next num
End Sub
Function GetColor(Color As Long) As String
Select Case Color
Case Is = -16777216
GetColor = "自动色"
Case Is = 0
GetColor = "黑色"
Case Is = 13209
GetColor = "褐色"
Case Is = 13107
GetColor = "橄榄绿"
Case Is = 13056
GetColor = "深绿" Case Is = 6697728 GetColor = "深灰蓝" Case Is = 8388608 GetColor = "深蓝" Case Is = 10040115 GetColor = "靛蓝" Case Is = 3355443 GetColor = "灰色-80%" Case Is = 128 GetColor = "深红" Case Is = 26367 GetColor = "桔黄" Case Is = 32896 GetColor = "深黄" Case Is = 32768 GetColor = "绿色" Case Is = 8421376 GetColor = "蓝绿色" Case Is = 16711680 GetColor = "蓝色" Case Is = 10053222 GetColor = "蓝-灰" Case Is = 8421504 GetColor = "灰色-50%" Case Is = 255
GetColor = "红色" Case Is = 39423 GetColor = "浅桔黄" Case Is = 52377 GetColor = "酸橙色" Case Is = 6723891 GetColor = "海绿" Case Is = 13421619 GetColor = "宝石蓝" Case Is = 16737843 GetColor = "浅蓝" Case Is = 8388736 GetColor = "紫色" Case Is = 10066329 GetColor = "灰色-40%" Case Is = 16711935 GetColor = "粉红" Case Is = 52479 GetColor = "金色" Case Is = 65535 GetColor = "黄色" Case Is = 65280 GetColor = "鲜绿" Case Is = 16776960 GetColor = "青绿" Case Is = 16763904