将邮件合并字段转换为Word中的可填写表单字段

时间:2011-02-06 20:22:03

标签: ms-word mailmerge word-2007

我准备了一个带有邮件合并字段的单词模板。

有没有一种简单的方法可以将它们转换为可填写的表单字段?

最后,我想创建一个可填写的pdf表单。

1 个答案:

答案 0 :(得分:2)

如果这是一个简单的遗产领域:

Public Sub ReplaceMergeFields()
    On Error GoTo MyErrorHandler

    Dim sourceDocument As Document
    Set sourceDocument = ActiveDocument

    Dim myMergeField As Field
    Dim i As Long
    For i = sourceDocument.Fields.Count To 1 Step -1
        Set myMergeField = sourceDocument.Fields(i)

        myMergeField.Select
        If myMergeField.Type = wdFieldMergeField Then
            Selection.FormFields.Add Range:=Selection.Range, Type:=wdFieldFormTextInput
        End If

        DoEvents
    Next

    Exit Sub

MyErrorHandler:
    MsgBox "ReplaceMergeFields" & vbCrLf & vbCrLf & "Err = " & Err.Number & vbCrLf & "Description: " & Err.Description
End Sub