Re: Remove special formatting characters from textbox contents
From: Peter Hewett (nospam_at_xtra.co.nz)
Date: 09/02/04
- Next message: Jason L: "Find Replace for numbering"
- Previous message: Howard Kaikow: "Something is opening Normal.dot"
- In reply to: Katherine: "Remove special formatting characters from textbox contents"
- Next in thread: Katherine: "Re: Remove special formatting characters from textbox contents"
- Reply: Katherine: "Re: Remove special formatting characters from textbox contents"
- Messages sorted by: [ date ] [ thread ]
Date: Fri, 03 Sep 2004 03:41:16 +1200
Hi Katherine
What I'd do is cut 'n paste specific character from the Word document into your TextBox
controls to isolate *exactly* what's causing the problem. If you're using Word 2000 or
later you can then use the Replace function to strip out the junk characters in the
Controls AfterUpdate event. You could do it in the controls Change event handler but that
event is triggered *every* time you add/delete/change a character in the control.
I'd strip out these characters which Word uses; Chr$(10) (or vbLf) for new line
(Shift+Enter ), Chr$(12) (or vbFormFeed) for section breaks (all types) and Chr$(13) (or
vbCr) for paragraph marks (Enter).
Private Sub txtA_AfterUpdate()
Dim strText As String
' Strip Newline, Paragraph mark and section breaks
strText = Replace(txtA.Text, vbLf, vbNullString)
strText = Replace(strText, vbCr, vbNullString)
txtA.Text = Replace(strText, vbFormFeed, vbNullString)
End Sub
The above assumes your TextBox control is named "txtA". Also, I've just completely
deleted the character rather than replace it with another. This obviously will impact the
format of the text (as you want) but you may need to do something else if the final format
is not correct.
HTH + Cheers - Peter
Katherine <Katherine@discussions.microsoft.com>, said:
>Where users are cutting and pasting text into my userform textboxes, they are
>picking up paragraph marks etc. This is causing a runtime error when these
>details arte submitted into the custom document property fields in the word
>document. Cutting and pasting into the textbox from notepad doesn't produce
>an error, so we're pretty sure it's the formatting that's causing the
>problem.
>
>What I need to do is strip out all the paragraph marks etc from the textbox
>contents before they are submitted into the document. I figure I need some
>kind of if statement, but the actual syntax is beyond me - I have no idea
>where to begin.
>
>a - z, 1 - 0, full stops (periods) and spaces are all valid entries. How do
>I get rid of the other gumpf?
- Next message: Jason L: "Find Replace for numbering"
- Previous message: Howard Kaikow: "Something is opening Normal.dot"
- In reply to: Katherine: "Remove special formatting characters from textbox contents"
- Next in thread: Katherine: "Re: Remove special formatting characters from textbox contents"
- Reply: Katherine: "Re: Remove special formatting characters from textbox contents"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|