alignment issue in a document

A

Associates

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
 
D

Doug Robbins - Word MVP

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
 
G

Gordon Bentley-Mix

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).
 
F

Fumei2 via OfficeKB.com

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 said:
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).
[quoted text clipped - 33 lines]
Thank you in advance
 
F

Fumei2 via OfficeKB.com

And of course you could just as easily put the text ("RE" whatever...") into
a bookmark ( also using a Style), rather than using Selection.
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]
 
F

Fumei2 via OfficeKB.com

I am not exactly sure what is placed into the DOCVARIABLE, the whole text
including the line break, or not. But...it does not matter whatsoever, as
whatever it is, it is still only a string.
And of course you could just as easily put the text ("RE" whatever...") into
a bookmark ( also using a Style), rather than using Selection.
OR.....if you are properly using Styles.
[quoted text clipped - 36 lines]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top