0
我需要一個MS Word的VBA代碼,選擇多個表(我選擇)並輸入一個基於文本框對象的字符串。我已經寫了一個代碼來做到這一點,但是如果我選擇大量的表,它會變得重複。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
有沒有更簡單的方法來把這段代碼放在一起?