【发布时间】:2017-01-11 04:46:22
【问题描述】:
我需要一个用于 MS Word 的 VBA 代码,它可以选择多个表(我选择的)并根据文本框对象输入一个字符串。我已经编写了一个代码来执行此操作,但如果我要选择大量表,它会变得重复。
Private Sub Claim_Change()
Dim j As Table
Set j = ActiveDocument.Tables(2)
Dim k As Table
Set k = ActiveDocument.Tables(3)
'Input claim
j.Select
Selection.Delete
With j
.Cell(1, 1).Range.InsertAfter "Claim #: " & Claim
.Cell(1, 2).Range.Text = Format(Date, "MMMM DD, YYYY ")
.Columns.AutoFit
End With
k.Select
Selection.Delete
With k
.Cell(1, 1).Range.InsertAfter "Claim #: " & Claim
.Cell(1, 2).Range.Text = Format(Date, "MMMM DD, YYYY ")
.Columns.AutoFit
End With
Claim.Select
End Sub
有没有更简单的方法把这段代码放在一起?
【问题讨论】: