PDA

View Full Version : [SOLVED:] Looking for Assistance with Userform



IronFozzie
06-28-2019, 08:28 AM
Hello everyone,

I'm sorry if this has been posted before, but I've scoured the internet looking for someone else who's tried to do the same thing. I'm attempting to create a userform in Word that allows the user to track call information. Simply, I want the form to paste the data entered into the word document, then when a new form is submitted, it pastes the new information below the originally input information on the document.

I'm aware this might be easier to do in excel, however, the limitations of my environment prevent excel from being the best solution. The data from this form would be translated by the employee or user to an overall tracker in excel using a userform, preventing the copy and paste functions from this document if it were to be in excel. I've placed some screen shots of my intended outcome below and any assistance you can offer would be greatly appreciated.

The new document is created, user clicks New Call and form shows. (This I've been able to accomplish.)
24523
User inputs information and clicks submit to paste to document. (I have been able to accomplish this with bookmarks, although I'm not sure if this is the best solution.)
24524
Pasted information shows on document. User selects New Call for next call.
24525
User inputs new call information into blank form.
24526
New call information submitted pastes below the original information with a horizontal rule separating the two calls.
24527

gmayor
06-28-2019, 08:35 PM
You don't need Bookmarks. Assuming the controls on the userform have the default names (otherwise change them in the code) then


Private Sub CommandButton1_Click() ActiveDocument.Range.InsertAfter "Name: " & TextBox1.Text & vbCr
ActiveDocument.Range.InsertAfter "Location: " & TextBox2.Text & vbCr
If OptionButton1.Value = True Then
ActiveDocument.Range.InsertAfter "Call Type: A"
End If
If OptionButton2.Value = True Then
ActiveDocument.Range.InsertAfter "Call Type: B"
End If
If OptionButton3.Value = True Then
ActiveDocument.Range.InsertAfter "Call Type: C"
End If
ActiveDocument.Range.InsertAfter Chr(11) & "_______________________________________________________________" & vbCr & vbCr
Unload Me
End Sub