'Importing doc variables from a Word document into another

I have a Word document with a userform that allows users to complete a series of questions (filing out textboxes) that populates a Word document. The userform utilizes doc variables to mark where in the document I want answers to be populated. The code looks like:

Dim TextBox13 As Range
    ActiveDocument.Variables("dvmdy").Value = Me.TextBox13.Value
    Me.TextBox13.Value = Me.TextBox13.Text
    
    With ActiveDocument

    .Fields.Update

    End With

I also have a command button that works to open another document but am trying to make it so it reads the docvariables in the second document and writes them to the first. The code below is for the file selector setup I put together:

Private Sub CommandButton1_Click()

    Dim fDialog As FileDialog

    Dim strFile1 As String

    Dim strFile2 As String


    Set fDialog = Application.FileDialog(msoFileDialogFilePicker)

    With fDialog

        .Filters.Clear

        .Filters.Add "Word Documents", "*.docm*"

        .InitialFileName = "C:\"

        .Title = "Select the First Document"

        If .Show = -1 Then

            strFile1 = .SelectedItems(1)
            strFile1 = .SelectedItems(1)
            MsgBox (strFile1)
            Label8v = strFile1
        Else

            Exit Sub

        End If

    End With

    With fDialog

        .Filters.Clear

        .Filters.Add "Word Documents", "*.docm*"

        .InitialFileName = "C:\"

        .Title = "Select the Second Document"

        If .Show = -1 Then

            strFile2 = .SelectedItems(1)
            strFile2 = .SelectedItems(1)
            MsgBox (strFile2)
            Label9v = strFile2
        Else

            Exit Sub

        End If

    End With

Set Doc1 = Documents.Open(strFile1)

Set Doc2 = Documents.Open(strFile2)

End Sub

Basically I want to make it so it allows users to open previously filled out Word documents with the same doc variables so that the previously filled out answers could be used to populate the new document/userform.



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source