|
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
前提:你的宏安全性必须设为低,如果为高,则必须在工具/宏/安全性:设为低后关闭并重启Word,打开此文档.注意菜单右上方的"SetEnglishLines"命令,按此命令,可绘出你需要的格线.
这只是一个试验,其实有几种方法可以做到,当然,都离不开绘图:一是在页眉页脚中实现,则此格线相当于水印或者背景.如果纯粹按楼主的意图:所有设置均基于每一行为一个段落的基础上进行,请务必注意.你有两种实现方法,在此文档中,按下ENTER键预置很多空白段落,然后点"SetEnglishLines"命令,则先于英文前绘制了格线;也可以录入全部英文后再点击此命令,但注意,此时你的字体必须设置为"Times New Roman",字号为13.5号,并且每一行为一个段落,否则会出现功能紊乱,当然,如果你觉得此法可行,我还可以进一步开发代码.
基于选定内容时,只会对选定内容进行格线的绘制工作;当未选定内容时,对全文档进行格线的绘制工作.
示例 :注意每行为一个段落!
以下代码供参考:
'* +++++++++++++++++++++++++++++
'* Created By 守柔(ShouRou)@ExcelHome 2005-3-6 7:54:14
'仅测试于System: Windows NT Word: 10.0 Language: 2052
'^The Code CopyIn [ThisDocument-ThisDocument]^'
'* -----------------------------
Option Explicit
Sub SetEnglishLines()
Dim i As Paragraph, MyLine As Shape, MyShape As Shape, MyRange As Range, H As Integer
Dim WP As Single, PP As Single, TP As Single, LP As Single, RP As Single, N As Byte
On Error Resume Next '忽略错误
With ActiveDocument.PageSetup
WP = .PageWidth '页面宽度
LP = .LeftMargin '左页边距
RP = .RightMargin '右页边距
End With
'根据区域不同,进行设置,如果未选定内容则在全文档中进行,反之则在选定区域中进行
If Selection.Type = wdSelectionIP Then
Set MyRange = ActiveDocument.Content
Else
Set MyRange = Selection.Range
End If
Application.ScreenUpdating = False '关闭屏幕更新
For Each i In MyRange.Paragraphs '在指定区域中循环
H = H + 1 '计数
With i.Range '对段落进行初始化设置,以达到要求
.Font.Size = 13.5 '字号
.Font.Name = "Times New Roman" '字体
.ParagraphFormat.SpaceBefore = 0 '段前为0
.ParagraphFormat.SpaceAfter = 0 '段后为0
.ParagraphFormat.Space2 '2倍行距
TP = i.Range.Information(wdVerticalPositionRelativeToPage) + 5 '取得段落的垂直位置
For N = 0 To 3 '循环划直线
Set MyLine = ActiveDocument.Shapes.AddLine(LP, TP + 8 * N, WP - RP, TP + 8 * N)
MyLine.Name = "Line" & H & N
If N = 2 Then MyLine.Line.Weight = 1.5 '当N为2时的直线为1.5磅
Next
'组合四条直线
Set MyShape = ActiveDocument.Shapes.Range(Array _
("Line" & H & 0, "Line" & H & 1, "Line" & H & 2, "Line" & H & 3)).Group
MyShape.ZOrder msoSendBehindText '浮于文字下方
End With
Next
Application.ScreenUpdating = True '恢复屏幕更新
End Sub
'----------------------
附图:
mP0Hx8om.rar
(12.29 KB, 下载次数: 135)
|
-
[求助]请教版主:如何设置用于英语书写的横线及相关问题?
|