WendyHubard
New Member
- Joined
- Apr 4, 2017
- Messages
- 29
- Office Version
- 365
- 2016
- Platform
- Windows
Hello Guru's,
I've done something really dumb with one of my macro enabled templates. The userform appears and allows the user to enter the data, afterc licking the OK button, the word document populates, but the userform refreshes instead of hiding/closing/disappearing. If I select the OK button again, the userform will close. Any clues on what silly thing I have done?
I'm not sure what to include. Have just copied the VBA code....
Many thanks in advance.
I've done something really dumb with one of my macro enabled templates. The userform appears and allows the user to enter the data, afterc licking the OK button, the word document populates, but the userform refreshes instead of hiding/closing/disappearing. If I select the OK button again, the userform will close. Any clues on what silly thing I have done?
I'm not sure what to include. Have just copied the VBA code....
Many thanks in advance.
VBA Code:
Private Sub CommandButton1_Click()
Dim Complaint As Range
Set Complaint = ActiveDocument.Bookmarks("Complaint").Range
Complaint.Text = Me.TextBox1.Value
Dim File As Range
Set File = ActiveDocument.Bookmarks("File").Range
File.Text = Me.TextBox2.Value
Dim Accused As Range
Set Accused = ActiveDocument.Bookmarks("Accused").Range
Accused.Text = Me.TextBox3.Value
Dim Charges As Range
Set Charges = ActiveDocument.Bookmarks("Charges").Range
Charges.Text = Me.TextBox4.Value
Dim Accused2 As Range
Set Accused = ActiveDocument.Bookmarks("Accused2").Range
Accused.Text = Me.TextBox3.Value
Dim Complaint2 As Range
Set Complaint = ActiveDocument.Bookmarks("Complaint2").Range
Complaint.Text = Me.TextBox1.Value
Dim Charges2 As Range
Set Charges = ActiveDocument.Bookmarks("Charges2").Range
Charges.Text = Me.TextBox4.Value
Dim DateAppeared As Range
Set DateAppeared = ActiveDocument.Bookmarks("DateAppeared").Range
DateAppeared.Text = Me.TextBox5.Value
Dim DateAppeared2 As Range
Set DateAppeared = ActiveDocument.Bookmarks("DateAppeared2").Range
DateAppeared.Text = Me.TextBox5.Value
Dim Magistrate As Range
Set Magistrate = ActiveDocument.Bookmarks("Magistrate").Range
Magistrate.Text = Me.ComboBox1.Value
Dim Magistrates As Range
Set Magistrate = ActiveDocument.Bookmarks("Magistrate2").Range
Magistrate.Text = Me.ComboBox1.Value
Dim Court As Range
Set Court = ActiveDocument.Bookmarks("Court").Range
Court.Text = Me.ComboBox2.Value
Dim Court2 As Range
Set Court = ActiveDocument.Bookmarks("Court2").Range
Court.Text = Me.ComboBox2.Value
Dim Solicitor As Range
Set Solicitor = ActiveDocument.Bookmarks("Solicitor").Range
Solicitor.Text = Me.TextBox6.Value
Dim Solicitor2 As Range
Set Solicitor = ActiveDocument.Bookmarks("Solicitor2").Range
Solicitor.Text = Me.TextBox6.Value
Dim Firm As Range
Set Firm = ActiveDocument.Bookmarks("Firm").Range
Firm.Text = Me.TextBox7.Value
Dim Firm2 As Range
Set Firm = ActiveDocument.Bookmarks("Firm2").Range
Firm.Text = Me.TextBox7.Value
Dim Plea As Range
Set Plea = ActiveDocument.Bookmarks("Plea").Range
Plea.Text = Me.ComboBox3.Value
Dim Plea2 As Range
Set Plea = ActiveDocument.Bookmarks("Plea2").Range
Plea.Text = Me.ComboBox3.Value
Dim SupremeDate As Range
Set SupremeDate = ActiveDocument.Bookmarks("SupremeDate").Range
SupremeDate.Text = Me.TextBox8.Value
Dim SupremeDate2 As Range
Set SupremeDate = ActiveDocument.Bookmarks("SupremeDate2").Range
SupremeDate.Text = Me.TextBox8.Value
Dim outcome As Range
Set outcome = ActiveDocument.Bookmarks("Outcome").Range
outcome.Text = Me.ComboBox4.Value
Dim outcome2 As Range
Set outcome = ActiveDocument.Bookmarks("Outcome2").Range
outcome.Text = Me.ComboBox4.Value
Dim outcome3 As Range
Set outcome = ActiveDocument.Bookmarks("Outcome3").Range
outcome.Text = Me.ComboBox4.Value
Dim outcome4 As Range
Set outcome = ActiveDocument.Bookmarks("Outcome4").Range
outcome.Text = Me.ComboBox4.Value
'Me.Repaint
'UserForm1.Hide
'UserForm1.Close
Unload UserForm1
'Unload Me
End Sub
Last edited by a moderator: