Hey All,
I'm completely new to this, so forgive my ignorance. All I'm doing is creating a Form for a template with a few fields. What I want to do is fill out the form, and then update the DocVariables in the word document. The form works fine when I run it from the VBA editor, however when I try to create a new document with the template it only updates some of the DocVariables.
It will update the Title, and the Name/ID/Course/Assignment in the header of the second page. However, it WONT update the Name/ID/Course/Assignment DocVariables on the first page. I'm assuming its just a simple error in some of my logic - the following is the code I'm using:
Code:
Sub CallUF()
Dim oFrm As Assignment
Dim oVars As Word.Variables
Set oVars = ActiveDocument.Variables
Set oFrm = New Assignment
With oFrm
.Show
If .boolProceed Then
oVars("varTitle").Value = .tTitle
oVars("varName").Value = .tName
oVars("varStudent").Value = .tStudent
oVars("varCourse").Value = .tCourse
oVars("varAssignment").Value = .tAssignment
myUpdateFields
Else
MsgBox "Form cancelled by user"
End If
End With
Unload oFrm
Set oFrm = Nothing
Set oVars = Nothing
End Sub
Sub myUpdateFields()
Dim pRange As Word.Range
For Each pRange In ActiveDocument.StoryRanges
Do
pRange.Fields.Update
Set pRange = pRange.NextStoryRange
Loop Until pRange Is Nothing
Next
End Sub
Thanks Very Much Everyone!
