Reputation: 1982
When having someone enter an input in a TextBox in VBA in Word 2016 64bit if they enter a blank line at the end of the textbox the program crashes and throws this error out. I can not figure out how to fix this and do not know what to try.
TextBox:
Code:
Set ccs = ActiveDocument.SelectContentControlsByTag("CreditNotes")
Set cc = ccs(1)
cc.Range.Text = CreditNotes.Text'
I then get the 5844 error but only if there is a blank line at the end of the textbox. Otherwise it works.
What code should I use to automatically take out the blank line so this will not throw out an error?
Upvotes: 0
Views: 489
Reputation: 144
You might try:
cc.Range.Text = Replace(CreditNotes.Text, vbCrLf, vbNullString)
Upvotes: 2