From: Associates on 19 Apr 2010 23:49 Hi, I have a question I would like to ask. I have a userform that allows users to enter their project details. I use DOCVARIABLE to put a multiline texts into the document. So, in the document, i have the following: Re: some subjects I use a multiline textbox to allow user to enter more than one line of texts. These texts are to be placed in the "Re:" My question is whether or not there are ways of aligning it properly as follows For example, we have two lines of texts: Rehabilitation Report 2005 - 2010 At the moment, if i enter those data into the document, I'd get as follows Re: Rehabilitation Report 2005 - 2010 But I would like to be able to do is to align them straight as follows Re: Rehabilitation Report 2005 - 2010 Just wonder if this is feasible. Any helps would be greatly appreciated. Thank you in advance
From: Doug Robbins - Word MVP on 20 Apr 2010 00:59 Try using a two column borderless table with the Re is the first column and the docvariable field in the second. -- Hope this helps. Please reply to the newsgroup unless you wish to avail yourself of my services on a paid consulting basis. Doug Robbins - Word MVP, originally posted via msnews.microsoft.com "Associates" <Associates(a)discussions.microsoft.com> wrote in message news:016A2A7B-3235-4B31-9485-AB96474591A5(a)microsoft.com... > Hi, > > I have a question I would like to ask. > > I have a userform that allows users to enter their project details. I use > DOCVARIABLE to put a multiline texts into the document. > > So, in the document, i have the following: > > Re: some subjects > > I use a multiline textbox to allow user to enter more than one line of > texts. These texts are to be placed in the "Re:" > > My question is whether or not there are ways of aligning it properly as > follows > > For example, we have two lines of texts: > > Rehabilitation Report > 2005 - 2010 > > At the moment, if i enter those data into the document, I'd get as follows > > Re: Rehabilitation Report > 2005 - 2010 > > But I would like to be able to do is to align them straight as follows > > Re: Rehabilitation Report > 2005 - 2010 > > Just wonder if this is feasible. > > Any helps would be greatly appreciated. > > Thank you in advance
From: Gordon Bentley-Mix on 20 Apr 2010 01:29 Doug's method is probably the method that I would use as well. However, if there's a specific reason that you don't want to use a table and must use a hanging indent, then the following should help you parse the value from a Multiline TextBox: Function CleanUpMultilineValue(myValue As String) As String Dim Temp As String Temp = "" If Len(myValue) > 0 Then Dim i As Integer For i = Len(myValue) To 1 Step -1 Select Case Mid(myValue, i, 1) Case vbLf 'do nothing Case vbCr Temp = Chr(11) & Temp Case Else Temp = Mid(myValue, i, 1) & Temp End Select Next i If Mid(Temp, Len(Temp), 1) = Chr(11) Then Temp = Mid(Temp, 1, Len(Temp) - 1) End If CleanUpMultilineValue = Temp End Function The function takes in the .Value from the TextBox ("myValue") and returns a String value in which the LF/CR pair is replaced with a Chr(11) character (soft return). -- Cheers! Gordon Bentley-Mix "Associates" <Associates(a)discussions.microsoft.com> wrote in message news:016A2A7B-3235-4B31-9485-AB96474591A5(a)microsoft.com... > Hi, > > I have a question I would like to ask. > > I have a userform that allows users to enter their project details. I use > DOCVARIABLE to put a multiline texts into the document. > > So, in the document, i have the following: > > Re: some subjects > > I use a multiline textbox to allow user to enter more than one line of > texts. These texts are to be placed in the "Re:" > > My question is whether or not there are ways of aligning it properly as > follows > > For example, we have two lines of texts: > > Rehabilitation Report > 2005 - 2010 > > At the moment, if i enter those data into the document, I'd get as follows > > Re: Rehabilitation Report > 2005 - 2010 > > But I would like to be able to do is to align them straight as follows > > Re: Rehabilitation Report > 2005 - 2010 > > Just wonder if this is feasible. > > Any helps would be greatly appreciated. > > Thank you in advance
From: Fumei2 via OfficeKB.com on 20 Apr 2010 15:33 OR.....if you are properly using Styles. The RE: paragraph using "MyBaseText" The next line using "MyIndent" Private Sub CommandButton1_Click() Dim strLine1 As String Dim strLine2 As String If InStr(TextBox1.Text, vbLf) > 0 Then strLine1 = Left(TextBox1.Text, InStr(TextBox1.Text, vbLf)) strLine2 = Right(TextBox1.Text, InStr(TextBox1.Text, vbLf)) strLine1 = "RE: " & strLine1 With Selection .Style = "MyBaseText" .TypeText strLine1 .Style = "MyIndent" .TypeText strLine2 .Expand Unit:=wdSentence .Collapse 1 .TypeBackspace End With Else MsgBox "hmmmm" End If Unload Me End Sub It grabs the text before the linebreak inside the textbox string, uses THAT with "RE" and the style "MyBaseText". It grabs the text AFTER the linebreak in the textbox and uses that with the style MyIndent....thus the indent is buiilt-in, and no need for tables. Just an alternative. Gerry Gordon Bentley-Mix wrote: >Doug's method is probably the method that I would use as well. However, if >there's a specific reason that you don't want to use a table and must use a >hanging indent, then the following should help you parse the value from a >Multiline TextBox: > >Function CleanUpMultilineValue(myValue As String) As String >Dim Temp As String > Temp = "" > If Len(myValue) > 0 Then > Dim i As Integer > For i = Len(myValue) To 1 Step -1 > Select Case Mid(myValue, i, 1) > Case vbLf > 'do nothing > Case vbCr > Temp = Chr(11) & Temp > Case Else > Temp = Mid(myValue, i, 1) & Temp > End Select > Next i > If Mid(Temp, Len(Temp), 1) = Chr(11) Then Temp = Mid(Temp, 1, >Len(Temp) - 1) > End If > CleanUpMultilineValue = Temp >End Function > >The function takes in the .Value from the TextBox ("myValue") and returns a >String value in which the LF/CR pair is replaced with a Chr(11) character >(soft return). >> Hi, >> >[quoted text clipped - 33 lines] >> >> Thank you in advance -- Gerry Message posted via http://www.officekb.com
From: Fumei2 via OfficeKB.com on 20 Apr 2010 15:34 And of course you could just as easily put the text ("RE" whatever...") into a bookmark ( also using a Style), rather than using Selection. Fumei2 wrote: >OR.....if you are properly using Styles. > >The RE: paragraph using "MyBaseText" >The next line using "MyIndent" > >Private Sub CommandButton1_Click() >Dim strLine1 As String >Dim strLine2 As String >If InStr(TextBox1.Text, vbLf) > 0 Then > strLine1 = Left(TextBox1.Text, InStr(TextBox1.Text, vbLf)) > strLine2 = Right(TextBox1.Text, InStr(TextBox1.Text, vbLf)) > strLine1 = "RE: " & strLine1 > With Selection > .Style = "MyBaseText" > .TypeText strLine1 > .Style = "MyIndent" > .TypeText strLine2 > .Expand Unit:=wdSentence > .Collapse 1 > .TypeBackspace > End With >Else > MsgBox "hmmmm" >End If >Unload Me >End Sub > >It grabs the text before the linebreak inside the textbox string, uses THAT >with "RE" and the style "MyBaseText". It grabs the text AFTER the linebreak >in the textbox and uses that with the style MyIndent....thus the indent is >buiilt-in, and no need for tables. > >Just an alternative. > >Gerry >>Doug's method is probably the method that I would use as well. However, if >>there's a specific reason that you don't want to use a table and must use a >[quoted text clipped - 30 lines] >>> >>> Thank you in advance > -- Gerry Message posted via http://www.officekb.com
|
Next
|
Last
Pages: 1 2 Prev: find and delete text box Next: Removing tables while preserving content |