我有一个列表格式列表的文档。我尝试将changebullet
与findbullet
中的两个潜艇组合在一起。我试图让findbullet
循环浏览文档并转到列表索引中的新列表。然后我尝试使用changebullet
循环遍历if语句以查看contentcontrol中是否存在字符串(我使用Selectcase
进行了辩论)。
想法是在内容控件的下拉列表中选择一个项目(在本例中为ContentControls(1)),然后单击命令按钮以触发Changebullet
。您可以看到我试图在代码中输入的项目符号列表。在changebullet
顶部的所有mumbo jumbo中,它会在#34;符号中生成一个很好的列表"字体样式。它最后不会将子弹添加到列表中它不会保持文本的字体为" Times New Roman"它将所有内容更改为符号(只有子弹需要是符号)。
我遇到了有关已经使用的语句的编译错误,或者找不到End with的错误,如果找不到则结束。
更新/编辑:我经历了一些迭代并解决了我的问题。下面是错误列表,然后是修复列表。
解决问题
ActiveDocument.Lists(1).Range.Select
这允许宏只与我试图操作的列表进行交互"列表1" ContinuePreviousList:=True
这允许文本插入显示项目符号并保留列表1. 我从这个错过的机会中拿走的东西。获取宏以选择我想要与之交互的部分,或者让光标移动到我想要与Document交互的位置。要保持列表索引不被破坏并添加/调整项目符号列表,请继续前面的列表等于true。
)
Sub changebullets ()
Dim oPara As Word.Paragraph
Dim i As Long
Dim HCE As Long
Dim CntCtrl As Variant
CntCtrl = ActiveDocument.ContentControls(1).Range.Text
HCE = ActiveDocument.Lists.Count
With Selection
If InStr(ActiveDocument.ContentControls(1).Range.Text, "DropDownItem1") Then
ActiveDocument.Lists(1).Range.Select
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:=True, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:=wdWord10ListBehavior
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = InchesToPoints(0.25)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.25)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Size = 8
.Name = "Symbol"
End With
.LinkedStyle = ""
End With
Selection.Font.Name = "Times New Roman"
Selection.TypeText Text:="Hello does it work yet?"
Selection.TypeParagraph
Selection.TypeText Text:="New Bullet Mother Trucker."
Selection.TypeParagraph
Selection.TypeText Text:="Second Bullet Mother Trucker."
Selection.TypeParagraph
Selection.TypeText Text:="Third Bullet Mother Trucker."
Selection.TypeParagraph
Selection.TypeText Text:="Fourth Bullet Mother Trucker."
End If
If InStr(ActiveDocument.ContentControls(1).Range.Text, "DropDownItem2") Then
ActiveDocument.Lists(1).Range.Select
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:=True, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:=wdWord10ListBehavior
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = InchesToPoints(0.25)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Size = 8
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = "Symbol"
End With
.LinkedStyle = ""
End With
Selection.Font.Name = "Times New Roman"
Selection.TypeText Text:="Xtina is a well dressed Environmental Scientist."
Selection.TypeParagraph
Selection.TypeText Text:="Micah has King Ranch Chicken that he'd like to eat."
Selection.TypeParagraph
Selection.TypeText Text:="Where you ever in college."
Selection.TypeParagraph
Selection.TypeText Text:="Josh is a Madman and he has Tattoos."
Selection.TypeParagraph
Selection.TypeText Text:="Fourth Bullet Mother Trucker."
End If
If InStr(ActiveDocument.ContentControls(1).Range.Text, "DropDownItem3") Then
ActiveDocument.Lists(1).Range.Select
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:=True, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:=wdWord10ListBehavior
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = InchesToPoints(0.25)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Size = 8
.Animation = wdUndefined
.DoubleStrikeThrough = wdUndefined
.Name = "Symbol"
End With
.LinkedStyle = ""
End With
Selection.Font.Name = "Times New Roman"
Selection.TypeText Text:="Dick Whitmen."
Selection.TypeParagraph
Selection.TypeText Text:="Wagner."
Selection.TypeParagraph
Selection.TypeText Text:="Gesting."
Selection.TypeParagraph
Selection.TypeText Text:="Jasmin."
Selection.TypeParagraph
Selection.TypeText Text:="Fourth Bullet Mother Trucker."
End If
If InStr(ActiveDocument.ContentControls(1).Range.Text, "DropDownItem4") Then
ActiveDocument.Lists(1).Range.Select
ListGalleries(wdBulletGallery).ListTemplates(1).Name = ""
Selection.Range.ListFormat.ApplyListTemplateWithLevel ListTemplate:=ListGalleries(wdBulletGallery).ListTemplates(1), ContinuePreviousList:=True, ApplyTo:=wdListApplyToSelection, DefaultListBehavior:=wdWord10ListBehavior
With ListGalleries(wdBulletGallery).ListTemplates(1).ListLevels(1)
.NumberFormat = ChrW(61623)
.TrailingCharacter = wdTrailingTab
.NumberStyle = wdListNumberStyleBullet
.NumberPosition = InchesToPoints(0.25)
.Alignment = wdListLevelAlignLeft
.TextPosition = InchesToPoints(0.5)
.TabPosition = wdUndefined
.ResetOnHigher = 0
.StartAt = 1
With .Font
.Size = 8
.Name = "Symbol"
End With
.LinkedStyle = ""
End With
Selection.Font.Name = "Times New Roman"
Selection.TypeText Text:="Ready Mix."
Selection.TypeParagraph
Selection.TypeText Text:="Dump Trucks doing Stuff."
Selection.TypeParagraph
Selection.TypeText Text:="Mad men is a crazy show."
Selection.TypeParagraph
Selection.TypeText Text:="The IBM computer was installed."
Selection.TypeParagraph
Selection.TypeText Text:="Stubblefield Coddington Whinchell 3rd."
End If
End With
End Sub
答案 0 :(得分:3)
你没有完成for each
If InStr(ActiveDocument.ContentControls(1).Range.Text, "ISWPPP") Then
For Each oPara In ActiveDocument.ListParagraphs
并在所有
结束时 End If
Next oPara