Home   Courses   TechHelp   Help   Contact   Merch   Join   Order   Logon   Forums   
 
Back to Word Forum    Comments List
Upload Images   @Reply   Bookmark    Link   Email   Next Unseen 
More Userform Issues
Daniel Golden 
     
19 months ago
In my UserForm, I have several boxes where the user enters text. These are set to allow for multi-line AND word wrap. The issue I am running into is that if the user wants to enter a second paragraph, they press shift + and it moves to a new line in the box which is great, except when they press the button to send the information from the UserForm to the document, it throws a run time error 5844 saying One of the values passed to this method or property is incorrect. I tried using the "help" button but it showed that there was no help found.

I know that if I type data in the box without pressing shift + enter to go to the next line that when it gets to the end of the box it will wrap the text but that is not a solution I am ok with.
Daniel Golden OP  @Reply  
     
19 months ago
For what it is worth, most of my text boxes on my form are rich text content control and I have tried plain-text content control allowing carriage returns as well with the same result.
Alex Hedley  @Reply  
           
19 months ago
At what point is the error thrown?

Can you clear the last line when you lose focus on that textbox?

Replace(CONTROL.Text, vbCrLf, vbNullString)
Daniel Golden OP  @Reply  
     
19 months ago
Alex,

I created a new form as a test to see if I could replicate the issue I'm having in my initial document. I put a rich text content control box and a plain-text context control box onto a new document and created a simple userform with the same VBA code used in my inital form. Both content control boxes on the test document did as I wanted them to do without any error being thrown...

This is a sample of the VBA Code in the userform of my original document:

DetailsPrivate Sub OKBtn_Click()

    Dim doc As Document
    Dim cc As ContentControl
    
    Set doc = ActiveDocument

For Each cc In doc.ContentControls
    If cc.Title = "CVSAExams" Then
        cc.Range.Text = Me.CVSAExams.Text
    End If
Next

End Sub
Daniel Golden OP  @Reply  
     
19 months ago
When the error is thrown, the line "cc.Range.Text = Me.CVSAExams.Text is highlighted in the VBA window which in my VERY limited experience tells me it has to be something with the code in the userform not the boxes in the document right?
Alex Hedley  @Reply  
           
19 months ago
Can you try the above code I sent before the line that errors?
Just set the output to another variable and use that as the assignment.
Daniel Golden OP  @Reply  
     
19 months ago
Im lost on how to make that happen....
Daniel Golden OP  @Reply  
     
19 months ago
There are several other text boxes ahead of the one I have listed, they all throw the same error code when I try to insert text that has a line break in it. If I just type and forgo the line break it inserts into the document without problems but like I said, I do not want to do that, especially when it works in my test document.
Alex Hedley  @Reply  
           
19 months ago
If new lines are causing the problem my suggestion is to try and remove them programmatically in any of your textboxes.
So before you are the output, strip them from the input.

This thread is now CLOSED. If you wish to comment, start a NEW discussion in Word Forum.
 

Next Unseen

 
 
What's This?

 

The following is a paid advertisement
Computer Learning Zone is not responsible for any content shown or offers made by these ads.
 

Learn
 
Access - index
Excel - index
Word - index
Windows - index
PowerPoint - index
Photoshop - index
Visual Basic - index
ASP - index
Seminars
More...
Customers
 
Login
My Account
My Courses
Lost Password
Memberships
Student Databases
Change Email
Info
 
Latest News
New Releases
User Forums
Topic Glossary
Tips & Tricks
Search The Site
Code Vault
Collapse Menus
Help
 
Customer Support
Web Site Tour
FAQs
TechHelp
Consulting Services
About
 
Background
Testimonials
Jobs
Affiliate Program
Richard Rost
Free Lessons
Mailing List
PCResale.NET
Order
 
Video Tutorials
Handbooks
Memberships
Learning Connection
Idiot's Guide to Excel
Volume Discounts
Payment Info
Shipping
Terms of Sale
Contact
 
Contact Info
Support Policy
Mailing Address
Phone Number
Fax Number
Course Survey
Email Richard
[email protected]
Blog RSS Feed    YouTube Channel

LinkedIn
Copyright 2026 by Computer Learning Zone, Amicron, and Richard Rost. All Rights Reserved. Current Time: 9/5/2026 4:14:48 PM. PLT: 0s