Re: Insert new line in table
How are you adding the text to the table and how is the table formatted?
Re: Insert new line in table
Quote:
Originally Posted by silvrwood
When I insert a new line into a string that pulls into a table via a docvariable I get a box of sorts. I've tried vbCrLf and Chr(13), both of which work elsewhere but not in the table.
The new lines are after LLP and before Oxnard
What can I use for a line feed within a table?
Have you tried Chr(10) & Chr(13)?
Re: Insert new line in table
vbCrLf is the same as Chr(10) & Chr(13). ;)
Re: Insert new line in table
Quote:
Originally Posted by RobDog888
vbCrLf is the same as Chr(10) & Chr(13). ;)
I know but I have noticed that you need to enter it in this particular order (Chr(13) & Chr(10)) for it to work in Access XP and prior Reports. See attached image. ;) :bigyello: :wave:
http://i11.photobucket.com/albums/a1...mbo/VBCRLF.jpg
Re: Insert new line in table
Alas, I had no luck with Chr(13) & Chr(10). I tried them in reverse just to be sure. Putting a space after the text on the first line at least enables the next line to drop to another line, but the boxes still appear.
In Word, in the document, I have inserted a docVariable field into a table. The table alignment is left with no text wrapping & standard margins. It is set to auto-resize to contents. The row is allowed to break across the page & there is no border. Am I leaving out anything that might be pertinent?
In the code I have created a string then assigned that string to the value of the docVariable:
Code:
Dim OptExecOO As String
OptExecOO = "Nordman Cormany Hair & Compton LLP " & Chr(13) & _
"1000 Town Center Drive, Sixth Floor " & Chr(13) & _
"Oxnard, California 93030"
'ActiveDocument.Variables.Add Name:="OptExec", Value:=" "
If ExecOutOpt.Value = True Then
ActiveDocument.Variables("OptExec").Value = OptExecOO
Else
ActiveDocument.Variables("OptExec").Value = OptExecIO
End If
Re: Insert new line in table
Have you tried vbNewLine?
1 Attachment(s)
Re: Insert new line in table
Did you try:
VB Code:
Dim OptExecOO As String
OptExecOO = "Nordman Cormany Hair & Compton LLP " & [COLOR=Red]Chr(13) & Chr(10)[/COLOR] & _
"1000 Town Center Drive, Sixth Floor " & [COLOR=Red]Chr(13) & Chr(10)[/COLOR] & _
"Oxnard, California 93030"
'ActiveDocument.Variables.Add Name:="OptExec", Value:=" "
If ExecOutOpt.Value = True Then
ActiveDocument.Variables("OptExec").Value = OptExecOO
Else
ActiveDocument.Variables("OptExec").Value = OptExecIO
End If
I used the following code in order to produce the attached image:
VB Code:
Dim OptExecOO As String
OptExecOO = "Nordman Cormany Hair & Compton LLP " & Chr(13) & Chr(10) & _
"1000 Town Center Drive, Sixth Floor " & Chr(13) & Chr(10) & _
"Oxnard, California 93030"
Me.Text0 = OptExecOO
Re: Insert new line in table
Quote:
Originally Posted by Hack
Have you tried vbNewLine?
This solution also will work for you.
Re: Insert new line in table
For some reason none of those solutions are working for me in a Word 2003 table. They work fine elsewhere in the document. Part of it seems to be related to the font. We use Century Schoolbook. When I change the font the box looks more like a hidden box, but it still consumes a space on the line before the start of the text as opposed to at the end of the preceeding line where it would not take up space.
For the time being I have added spaces between the text to force it to wrap at the margin.
Re: Insert new line in table
Where exactly is the string coming from? Are you sure it doesn't have the box character in it before you go pasting it into the table?
Otherwise try Chr(11) to add a soft-return?
Re: Insert new line in table
I declare a string in the User Form code, then set its value directly within the code, i.e.
Dim problemString As String
problemString = "Nordman Cormany Hair & Compton" & Chr(13) & _
"etc..."
So it's not pulling from anywhere else. I haven't tried Chr(11) yet. I will do that and respond accordingly.
Re: Insert new line in table
Quote:
Originally Posted by silvrwood
I declare a string in the User Form code, then set its value directly within the code, i.e.
Dim problemString As String
problemString = "Nordman Cormany Hair & Compton" & Chr(13) & _
"etc..."
So it's not pulling from anywhere else. I haven't tried Chr(11) yet. I will do that and respond accordingly.
Can you post a sample project?
Re: Insert new line in table
Quote:
Originally Posted by silvrwood
Alas, I had no luck with Chr(13) & Chr(10). I tried them in reverse just to be sure. Putting a space after the text on the first line at least enables the next line to drop to another line, but the boxes still appear.
In Word, in the document, I have inserted a docVariable field into a table. The table alignment is left with no text wrapping & standard margins. It is set to auto-resize to contents. The row is allowed to break across the page & there is no border. Am I leaving out anything that might be pertinent?
In the code I have created a string then assigned that string to the value of the docVariable:
Code:
Dim OptExecOO As String
OptExecOO = "Nordman Cormany Hair & Compton LLP " & Chr(13) & _
"1000 Town Center Drive, Sixth Floor " & Chr(13) & _
"Oxnard, California 93030"
'ActiveDocument.Variables.Add Name:="OptExec", Value:=" "
If ExecOutOpt.Value = True Then
ActiveDocument.Variables("OptExec").Value = OptExecOO
Else
ActiveDocument.Variables("OptExec").Value = OptExecIO
End If
It's the same as I indicated here.
Re: Insert new line in table
Hi,
The problem not ur script but MS Word template, for Word 2000 & 2003 u need to Place an Enter Key(new line) under the {DOCVARIABLE "YOUR_FIELD_NAME" \* MERGEFORMAT} field if ur field is in the table. If it's not in the table it's ok u wont see the square box.
I found a bug, If u don't add enter key under the "DOCVARIABLE" field & after u exported the data into the "DOCVARIABLE" field u will see the square box & if u place u cursor under the "DOCVARIABLE" field press Enter Key BOOM!!! ms word crash.
Foo.
Re: Insert new line in table
Thank you for this information. I will keep it if the firm decides to use this project again, or if such a need presents itself once more.