Jay
Fri Jul 11 19:40:45 PDT 2008
I'll assume that the first userform puts values into document variables, and
that the document displays those values in DocVariable fields, so the named
variables actually have values when the second userform launches.
The code for launching the second userform should look something like this:
Private Sub DisplayEditForm1()
Dim dlg As UserForm2 ' or whatever you named the second userform
Set dlg = New UserForm2
With ActiveDocument
dlg.txtProjectDescription = .Variables("ProjectDescription").Value
' etc.
End With
dlg.Show
Set dlg = Nothing
End Sub
Notice that txtProjectDescription is a text field in the userform, so it's a
member of dlg, indicated be the "dlg." in front of it. Do the same with the
other text fields in the userform.
Similarly, the .Variables collection is a member of the ActiveDocument object;
in this case, the ActiveDocument in front of .Variables is implied by the With
statement.
The dlg.Show is what makes the userform appear on screen. When the userform
hides itself (using Me.Hide in the code of the OK button), execution returns to
the next line in the macro, setting the dlg object to Nothing which frees the
userform's memory.
--
Regards,
Jay Freedman
Microsoft Word MVP FAQ:
http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so all
may benefit.
On Fri, 11 Jul 2008 15:31:00 -0700, Barb <Barb@discussions.microsoft.com> wrote:
>I have created a 2003 Word Template [2007 Compatibility Mode] that uses 2
>userforms. (The 2 userforms are identical, except for the Name and some of
>the VBA coding.)
>
>The first userform loads when the template opens as a document to which the
>user enters information in each field and upon clicking OK, the new document
>populates with the entered information.
>
>The second userform was created to appear with the help of a keyboard
>shortcut macro to appear so that the user has the option of changing the
>previously entered information.
>
>My problem is that I want the second userform to populate with the
>information that was previously entered. Here is a sampling of my code for
>the second userform:
>
>Private Sub DisplayEditForm1()
> With ActiveDocument
> txtProjectDescription =
>ActiveDocument.Variables("ProjectDescription").Value
> etc?..
> End With
>End Sub
>
>I have tried some of the other posted suggestions, but I'm still having
>problems.
>
>Does anyone have any suggestions?
>
>Thanks bunches!!