|
- Sub AddDocVariables()
- Dim doc As Document, doc_var As Variable
- Set doc = ActiveDocument
- For Each doc_var In doc.Variables
- doc_var.Delete
- Next
- With doc.Variables
- .Add Name:="addr", Value:=Replace(doc.Tables(1).Cell(3, 4).Range.Text, Chr(13) & Chr(7), "")
- .Add Name:="quanh", Value:=Replace(doc.Tables(1).Cell(6, 3).Range.Text, Chr(13) & Chr(7), "")
- .Add Name:="area", Value:=Replace(doc.Tables(1).Cell(6, 4).Range.Text, Chr(13) & Chr(7), "")
- End With
- ' For Each doc_var In doc.Variables
- ' Debug.Print doc_var.Value
- ' Next
- doc.Fields.Update
- End Sub
复制代码
附件中打绿色的部分是我做的,仅做了几处,供你参考,其它的你自己应该能学着做了。 |
|