View Full Version : Solved: Text formatting
fcoreyesv
04-21-2005, 09:17 AM
Hello,
I am copying a text from Word to a VB text box. I want to clean the format of the text from numbering and bullets before I pass it to the control in VB. :dunno
I am using the clipboard object to get the text.
Worddoc.Application.Selection.Copy()
Thank you in advance for your help :hi:
Joey
Killian
04-22-2005, 08:51 AM
You'll need to assign the text to a string variable first so you can do stuff with it.
If you're selection has bulleted or numbered styles, then the text property shouldn't be carrying those over. You will have to strip off paragraph mark at the end tho.Dim strText As String
strText = Application.Selection.Text
'get rid of paramark
If Right(strText, 1) = Chr(13) Then strText = Left(strText, Len(strText) - 1)
'remove leading and trailing spaces
strText = Trim(strText)
TextBox1.Text = strText
You'll need to assign the text to a string variable first so you can do stuff with it.
If you're selection has bulleted or numbered styles, then the text property shouldn't be carrying those over. You will have to strip off paragraph mark at the end tho.Dim strText As String
strText = Application.Selection.Text
'get rid of paramark
If Right(strText, 1) = Chr(13) Then strText = Left(strText, Len(strText) - 1)
'remove trailing spaces
strText = Trim(strText)
TextBox1.Text = strText
A small point: the Trim function will remove both leading and trailing spaces. LTrim and RTrim will remove just leading and trailing respectively. In the above case, I suspect that the removal of both leading and trailing is appropriate.
Killian
04-24-2005, 03:45 AM
Quite right. Which is what I did... I've edited my code comment appropriately
fcoreyesv
04-29-2005, 07:22 AM
Thanks guys. It worked just fine.
Powered by vBulletin® Version 4.2.5 Copyright © 2024 vBulletin Solutions Inc. All rights reserved.