这里有点小麻烦,我试图创建一个简单的宏来删除文档中所有表格的单元格填充,但由于某些未知原因,宏无法应用设置。手动操作(包括录制宏时)效果很好。
Sub Macro1()
'
' Macro1 Macro
'
'
Selection.HomeKey Unit:=wdStory
Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext, Count:=1, Name:=""
Selection.GoTo What:=wdGoToTable, Which:=wdGoToNext, Count:=1, Name:=""
Selection.Find.ClearFormatting
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Tables(1).Select
With Selection.Cells(1)
.TopPadding = CentimetersToPoints(0.05)
.BottomPadding = CentimetersToPoints(0.05)
.LeftPadding = CentimetersToPoints(0.05)
.RightPadding = CentimetersToPoints(0.05)
.WordWrap = True
.FitText = False
End With
End Sub
有什么想法吗?我什么想法都没有了。
欢呼吧,詹姆斯
答案1
您的代码设置为仅更改文档中的第一个表格,然后仅更改第一个选定的单元格。您实际想要的描述不清楚,但我假设您想要清除文档中所有现有表格中所有表格单元格的边距。
Sub YouSayPaddingISayMargin()
'sets the default margin sizes for all
'existing tables in the document
Dim tbl As Word.Table
For Each tbl In ActiveDocument.Tables
tbl.TopPadding = CentimetersToPoints(0)
tbl.BottomPadding = CentimetersToPoints(0)
tbl.LeftPadding = CentimetersToPoints(0)
tbl.RightPadding = CentimetersToPoints(0)
Next
子目录结束