|
自己改写了一个word多级列表的自定义宏(见下),目前可以正常使用。
但是需要弹出多次inputbox来选,比较烧脑。
百度查到inputbox,只能一次输入1个参数,想输入多个要用到窗体。
那么问题来了,请教大佬
1。inputbox是否真的只能输入1个?
2。窗体有没比较好的案例,网上没搜到。(小白,只会改,不会写)
Sub 多级()
'
'
'多级列表(wdOutlineNumberGallery)与项目符号级别(wdBulletGallery)
'
Dim di&, dj&, dk&, dl&, dm&, dn&
dx1 = InputBox("一级样式", "多级列表样式", "%1、")
If MsgBox("是:中文(否:数字)?", 4 + 48) = vbYes Then
di = 37
Else
di = 0
End If
dx2 = InputBox("二级样式", "多级列表样式", "%1.%2")
If MsgBox("是:中文(否:数字)?", 4 + 48) = vbYes Then
dj = 37
Else
dj = 0
End If
dx3 = InputBox("三级样式", "多级列表样式", "%1.%2.%3")
If MsgBox("是:中文(否:数字)?", 4 + 48) = vbYes Then
dk = 37
Else
dk = 0
End If
dx4 = InputBox("四级样式", "多级列表样式", "(%4)")
If MsgBox("是:中文(否:数字)?", 4 + 48) = vbYes Then
dl = 37
Else
dl = 0
End If
dx5 = InputBox("五级样式", "多级列表样式", "%5)")
If MsgBox("是:中文(否:数字)?", 4 + 48) = vbYes Then
dm = 37
Else
dm = 0
End If
dx6 = InputBox("六级样式", "多级列表样式", "%6.")
If MsgBox("是:中文(否:数字)?", 4 + 48) = vbYes Then
dn = 37
Else
dn = 0
End If
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = dx1
.TrailingCharacter = wdTrailingNone '指定在编号列表项的编号之后插入的字符/wdTrailingTab/wdTrailingNone
.NumberStyle = di 'https://docs.microsoft.com/zh-cn/office/vba/api/word.wdlistnumberstyle
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft 'https://docs.microsoft.com/zh-cn/office/vba/api/word.wdlistlevelalignment
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 0 '控制编号序列从哪开始是1
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = "标题 1"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(2)
.NumberFormat = dx2
.TrailingCharacter = wdTrailingNone
.NumberStyle = dj
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 1
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = "标题 2"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(3)
.NumberFormat = dx3
.TrailingCharacter = wdTrailingNone
.NumberStyle = dk
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 2
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = "标题 3"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(4)
.NumberFormat = dx4
.TrailingCharacter = wdTrailingNone
.NumberStyle = dl
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 3
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = "标题 4"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(5)
.NumberFormat = dx5
.TrailingCharacter = wdTrailingNone '无制符,wdTrailingSpace,wdTrailingTab
.NumberStyle = dm
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignLeft
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 4
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = "标题 5"
End With
With ListGalleries(wdOutlineNumberGallery).ListTemplates(1).ListLevels(6)
.NumberFormat = dx6
.TrailingCharacter = wdTrailingNone
.NumberStyle = dn
.NumberPosition = CentimetersToPoints(0)
.Alignment = wdListLevelAlignRight
.TextPosition = CentimetersToPoints(0)
.TabPosition = wdUndefined
.ResetOnHigher = 5
.StartAt = 1
With .Font
.Bold = wdUndefined
.Italic = wdUndefined
.StrikeThrough = wdUndefined
.Subscript = wdUndefined
.Superscript = wdUndefined
.Shadow = wdUndefined
.Outline = wdUndefined
.Emboss = wdUndefined
.Engrave = wdUndefined
.AllCaps = wdUndefined
.Hidden = wdUndefined
.Underline = wdUndefined
.Color = wdUndefined
.Size = wdUndefined
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = ""
End With
.LinkedStyle = "标题 6"
End With
ListGalleries(wdOutlineNumberGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:= _
ListGalleries(wdOutlineNumberGallery).ListTemplates(1), _
ContinuePreviousList:=True, ApplyTo:=wdListApplyToWholeList, _
DefaultListBehavior:=wdWord10ListBehavior
MsgBox "多级列表自动设置完成"
End Sub
搜索
复制
|
|