Select Case - break up long lines

L

Lenny

Is there a way to 'break' a long case result line? I tried placing an
underscore after the hyphen and doing a carrier return so Valid for listed
E/N only." would wrap to a second line but got an error asking for the
placement of an end sub. Can the result in select case be broken into
multiple lines? - Regards, Lenny

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - Valid for listed E/N
only."
would like to look like: TOOL DEVIATION -
Valid for listed E/N only."
 
J

Jean-Guy Marcil

Lenny said:
Is there a way to 'break' a long case result line? I tried placing an
underscore after the hyphen and doing a carrier return so Valid for listed
E/N only." would wrap to a second line but got an error asking for the
placement of an end sub. Can the result in select case be broken into
multiple lines? - Regards, Lenny

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - Valid for listed E/N
only."
would like to look like: TOOL DEVIATION -
Valid for listed E/N only."

You need more than an UNderscore character to signify to the compiler that
the String continues on a second line...

Try This:

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - " _
& "Valid for listed E/N
only."


Or:

Case "TD"
oDoc.FormFields("Text13").Result = _
"TOOL DEVIATION - " _
& "Valid for listed E/N only."
 
L

Lenny

Jean-Guy: I broke the line as you indicated below, but the line refuses to
budge from its single line entry. It is not breaking into 2 lines with
either of the configurations. Is there something I'm missing?

A quick aside: my company will be migrating to Office 2007 at the end of the
year and I believe the underlying code will be XML. Are there expected /
known problems with documents that are running VB code or continuing to use
VB?

Lenny - Regards
 
J

Jean-Guy Marcil

Lenny said:
Jean-Guy: I broke the line as you indicated below, but the line refuses to
budge from its single line entry. It is not breaking into 2 lines with
either of the configurations. Is there something I'm missing?

I am sorry but I do not understand what yu mean.

How can a line refuse to budge?
If you hit "Enter", it will budge!

Are you in the Word VBA window?
A quick aside: my company will be migrating to Office 2007 at the end of the
year and I believe the underlying code will be XML. Are there expected /
known problems with documents that are running VB code or continuing to use
VB?

XML-based documents (the new docx format) do not support VBA. For that, you
will need doc-format documents, as is the case with all previous versions.
VBA from previous versions should work with 2007 doc-format documents.
 
L

Lenny

Jean-Guy: In the VB editor, I tried breaking the line using both of the
examples you provided. Some additional info: The code is executed from a
dropdown inside a table cell as an exit macro. The select case line is
entered into a form field bookmarked as "Text 13" as referenced in the select
case code, into a different cell. Each one of the three items in the
dropdown, reference in the select case routing works great! It's just that
the Case TD item won't break, or wrap in the cell. Is the fact that the
receiving referenced cell is in a table cell the reason that it won't wrap?
I have used this same method in a legal letter that had very long lines and
it wrapped to the next line. But I have never tried to physically force the
line to break. I did press the 'enter' key after the underscore and let the
balance fall to the left margin, as well as tried indenting before the
amersand and the results keep appearing in the cell as one continuous line,
not two.... confused!

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - " _
& "Valid for listed E/N only."
Or:
Case "TD"
oDoc.FormFields("Text13").Result = _
"TOOL DEVIATION - " _
& "Valid for listed E/N only."
 
J

Jean-Guy Marcil

Lenny said:
Jean-Guy: In the VB editor, I tried breaking the line using both of the
examples you provided. Some additional info: The code is executed from a
dropdown inside a table cell as an exit macro. The select case line is
entered into a form field bookmarked as "Text 13" as referenced in the select
case code, into a different cell. Each one of the three items in the
dropdown, reference in the select case routing works great! It's just that
the Case TD item won't break, or wrap in the cell. Is the fact that the
receiving referenced cell is in a table cell the reason that it won't wrap?
I have used this same method in a legal letter that had very long lines and
it wrapped to the next line. But I have never tried to physically force the
line to break. I did press the 'enter' key after the underscore and let the
balance fall to the left margin, as well as tried indenting before the
amersand and the results keep appearing in the cell as one continuous line,
not two.... confused!

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - " _
& "Valid for listed E/N only."
Or:
Case "TD"
oDoc.FormFields("Text13").Result = _
"TOOL DEVIATION - " _
& "Valid for listed E/N only."

Ha, you mean that you want "TOOL DEVIATION - Valid for listed E/N only." to
wrap in the document, not in the code window.

If that is the case, then what I suggested will no help because I thought
you wanted to split the line in the Editor window on two lines...

Ok, let's start over...

When the text gets inserted in the document, if it is indeed inserted in a
text formfield (not a dropdown), it should wrap automatically, if it does not
you need to chek your document more carefully. Teh fact that it sits in a
cell is not relevant, unless of coursr, thee is enough space in the cell to
display thet ext on one line.

If you want to force a break, try this:

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - " _
& vbCrLf & "Valid for listed E/N only."

vbCrLf will insert a paragrpah mark "¶".

If you want a line break instead, try:

Case "TD"
oDoc.FormFields("Text13").Result = "TOOL DEVIATION - " _
& Chr(11) & "Valid for listed E/N only."
 
L

Lenny

Jean-Guy: you are marrrrvelous! works like a charm. thanks for sticking in
there with me - regards, Lenny
 

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