Template disappears

G

Guest

I created a userform for my template but when I fill it out and hit ok the
whole template disappears and Word sends me into a new document. Why does
this happen and how can I fix it?

Thanks,
Jill
 
J

Jay Freedman

I created a userform for my template but when I fill it out and hit ok the
whole template disappears and Word sends me into a new document. Why does
this happen and how can I fix it?

Thanks,
Jill

Remember my answer in your other thread, that there's no way to tell
without seeing the code? Well.... ditto. We need to know what you told
Word you wanted it to do. Post back and include both the code of the
macro that displays the userform, and the code in the userform itself.
 
G

Guest

I would cut and paste it but it won't let me into the template so here goes,
if I have to fix the code, how would I get back into the template, if it
won't let me?:

This is for the Userform:

Private Sub Document_New()

Dim oForm As frmDismissal

On Error Goto Error_DocumentNew

Set oForm = New frmDismissal
oForm.Tag = "Cancel"
oForm.txtDate.Text = Format$(Date, "mm/dd/yyyy")
oForm.Show

If oForm.Tag = "OK" Then
ActiveDocument.Bookmarks("ClientName").Range.Text = oForm.txtClientName.Text
ActiveDocument.Bookmarks("PetName").Range.Text = oForm.txtPetName.Text
ActiveDocument.Bookmarks("Doctor").Range.Text = oForm.txtDoctor.Text
ActiveDocument.Bookmarks("Date").Range.Text = oForm.txtDate.Text

Unload oForm
Set oForm = Nothing
Else
Unload oForm
Set oForm = Nothing
ActiveDocument.Close wdDoNotSaveChanges
End If

Exit_DocumentNew:

Exit Sub

Error_DocumentNew:
On Error Resume Next

Unload oForm
Set oForm = Nothing
ActiveDocument.Close wdDoNotSaveChanges

Resume Exit_DocumentNew

End Sub



Here's the next one (for the cancel button):

Option Explicit

Private Sub cmdCancel_Click()

Me.Hide

End Sub


Here's the ok button:

Private Sub cmdOK_Click()

Me.Tag = "OK"
Me.Hide

End Sub

Thanks for all your help!!!

Jill
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top