Reply
 
Thread Tools Display Modes
  #1   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax
--
I would give my left hand to be ambidextrous!
  #2   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

The built-in value named vbCr represents a paragraph mark (which is a
more accurate name for "carriage return" -- considering that a
typewriter carriage is now mostly obsolete). So you could construct
your string as

Result="Billy went out to the market. His ball was blue." & vbCr & _
"Jerry went to the school. His ball was yellow." & vbCr & _
"Mary stayed at home. She didn't have a ball."

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sat, 23 Jan 2010 09:15:01 -0800, Dax Arroway
wrote:

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax

  #3   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

The built-in value named vbCr represents a paragraph mark (which is a
more accurate name for "carriage return" -- considering that a
typewriter carriage is now mostly obsolete). So you could construct
your string as

Result="Billy went out to the market. His ball was blue." & vbCr & _
"Jerry went to the school. His ball was yellow." & vbCr & _
"Mary stayed at home. She didn't have a ball."

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sat, 23 Jan 2010 09:15:01 -0800, Dax Arroway
wrote:

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax

  #4   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

Ah yes, perfect! Thank you so much.
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

The built-in value named vbCr represents a paragraph mark (which is a
more accurate name for "carriage return" -- considering that a
typewriter carriage is now mostly obsolete). So you could construct
your string as

Result="Billy went out to the market. His ball was blue." & vbCr & _
"Jerry went to the school. His ball was yellow." & vbCr & _
"Mary stayed at home. She didn't have a ball."

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sat, 23 Jan 2010 09:15:01 -0800, Dax Arroway
wrote:

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax

.

  #5   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

Ah yes, perfect! Thank you so much.
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

The built-in value named vbCr represents a paragraph mark (which is a
more accurate name for "carriage return" -- considering that a
typewriter carriage is now mostly obsolete). So you could construct
your string as

Result="Billy went out to the market. His ball was blue." & vbCr & _
"Jerry went to the school. His ball was yellow." & vbCr & _
"Mary stayed at home. She didn't have a ball."

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sat, 23 Jan 2010 09:15:01 -0800, Dax Arroway
wrote:

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax

.



  #6   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

ARRrrrgh! Sufferin Suckatash! Gal-Darnit 255 character limit! Now I'm
throwing a Run-time error! I suppose the other answer is to put it in an
autotext entry. I'm trying to insert text into a table using a Macro. From
Doug Robins, my code is this:

Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 5"
Next i
End Select

However, when I replce the result string I pass the limit. This is a
template that will be opened by others not on the server so I'm trying to get
everything into the form itself. Is there a way to replce the string
designation with an AutoText??? And if so, what would the code look like?

--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

The built-in value named vbCr represents a paragraph mark (which is a
more accurate name for "carriage return" -- considering that a
typewriter carriage is now mostly obsolete). So you could construct
your string as

Result="Billy went out to the market. His ball was blue." & vbCr & _
"Jerry went to the school. His ball was yellow." & vbCr & _
"Mary stayed at home. She didn't have a ball."

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sat, 23 Jan 2010 09:15:01 -0800, Dax Arroway
wrote:

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax

.

  #7   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings


ARRrrrgh! Sufferin Suckatash! Gal-Darnit 255 character limit! Now I'm
throwing a Run-time error! I suppose the other answer is to put it in an
autotext entry. I'm trying to insert text into a table using a Macro. From
Doug Robins, my code is this:

Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 5"
Next i
End Select

However, when I replce the result string I pass the limit. This is a
template that will be opened by others not on the server so I'm trying to get
everything into the form itself. Is there a way to replce the string
designation with an AutoText??? And if so, what would the code look like?

--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

The built-in value named vbCr represents a paragraph mark (which is a
more accurate name for "carriage return" -- considering that a
typewriter carriage is now mostly obsolete). So you could construct
your string as

Result="Billy went out to the market. His ball was blue." & vbCr & _
"Jerry went to the school. His ball was yellow." & vbCr & _
"Mary stayed at home. She didn't have a ball."

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sat, 23 Jan 2010 09:15:01 -0800, Dax Arroway
wrote:

I have a Macro that inserts a string of text. The text however are a couple
of paragraphs which need to be broken up. What are the characters to do
this?

My code, for example, says this:
Result="Billy went out to the market. His ball was blue. Jerry went to the
school. His ball was yellow. Mary stayed at home. She didn't have a ball."


What's returned is this:
Billy went out to the market. His ball was blue. Jerry went to the school.
His ball was yellow. Mary stayed at home. She didn't have a ball.

What I'd like returned is this:
Billy went out to the market. His ball was blue.
Jerry went to the school. His ball was yellow.
Mary stayed at home. She didn't have a ball.

How do I do that??? Thanks in advance for any help.
--Dax

.

  #8   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

Don't fiddle with AutoText. Here's how to put more than 255 characters
into a form field:

http://www.word.mvps.org/FAQs/Macros...mFldResult.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 23 Jan 2010 15:25:01 -0800, Dax Arroway
wrote:

ARRrrrgh! Sufferin Suckatash! Gal-Darnit 255 character limit! Now I'm
throwing a Run-time error! I suppose the other answer is to put it in an
autotext entry. I'm trying to insert text into a table using a Macro. From
Doug Robins, my code is this:

Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 5"
Next i
End Select

However, when I replce the result string I pass the limit. This is a
template that will be opened by others not on the server so I'm trying to get
everything into the form itself. Is there a way to replce the string
designation with an AutoText??? And if so, what would the code look like?

  #9   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

Don't fiddle with AutoText. Here's how to put more than 255 characters
into a form field:

http://www.word.mvps.org/FAQs/Macros...mFldResult.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 23 Jan 2010 15:25:01 -0800, Dax Arroway
wrote:

ARRrrrgh! Sufferin Suckatash! Gal-Darnit 255 character limit! Now I'm
throwing a Run-time error! I suppose the other answer is to put it in an
autotext entry. I'm trying to insert text into a table using a Macro. From
Doug Robins, my code is this:

Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 5"
Next i
End Select

However, when I replce the result string I pass the limit. This is a
template that will be opened by others not on the server so I'm trying to get
everything into the form itself. Is there a way to replce the string
designation with an AutoText??? And if so, what would the code look like?

  #10   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

Don't fiddle with AutoText. Here's how to put more than 255 characters
into a form field:

http://www.word.mvps.org/FAQs/Macros...mFldResult.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 23 Jan 2010 15:25:01 -0800, Dax Arroway
wrote:

ARRrrrgh! Sufferin Suckatash! Gal-Darnit 255 character limit! Now I'm
throwing a Run-time error! I suppose the other answer is to put it in an
autotext entry. I'm trying to insert text into a table using a Macro. From
Doug Robins, my code is this:

Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 5"
Next i
End Select

However, when I replce the result string I pass the limit. This is a
template that will be opened by others not on the server so I'm trying to get
everything into the form itself. Is there a way to replce the string
designation with an AutoText??? And if so, what would the code look like?

.



  #11   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

Don't fiddle with AutoText. Here's how to put more than 255 characters
into a form field:

http://www.word.mvps.org/FAQs/Macros...mFldResult.htm

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sat, 23 Jan 2010 15:25:01 -0800, Dax Arroway
wrote:

ARRrrrgh! Sufferin Suckatash! Gal-Darnit 255 character limit! Now I'm
throwing a Run-time error! I suppose the other answer is to put it in an
autotext entry. I'm trying to insert text into a table using a Macro. From
Doug Robins, my code is this:

Dim ddresult As String
ddresult = Selection.FormFields(1).result
Select Case ddresult
Case "Level 1"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 1"
Next i
Case "Level 2"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 2"
Next i
Case "Level 3"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 3"
Next i
Case "Level 4"
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 4"
Next i
Case Else
For i = 2 To 5
Selection.Rows(1).Cells(i).Range.FormFields(1).res ult = "Result
for Level 5"
Next i
End Select

However, when I replce the result string I pass the limit. This is a
template that will be opened by others not on the server so I'm trying to get
everything into the form itself. Is there a way to replce the string
designation with an AutoText??? And if so, what would the code look like?

.

  #12   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

Hi Dax,

Please help me to help you. Reply to this thread with the following
information:

- The number and the exact and complete text of the error message.

- The entire code of the macro that has the error, copied from the VBA
editor and pasted into the newsgroup post.

- If the error message includes a Debug button, click it. That will
open the VBA editor and yellow-highlight the line where the error
occurred. In the code you include in the post, point to that line.

Even without that information, I'll take a quick guess at what's
wrong: The code you inserted refers to a string named Str1, but the
rest of your macro doesn't contain any string with that name. Change
Str1 to the name of the string that contains the text to be inserted
into the field. And put the three lines *after* the place in the macro
that assigns the text to that string.

To answer your other question, you need these three lines in *every*
macro that tries to assign a long (more than 255 characters) string to
a form field. Putting it into only one of those macros is not
sufficient.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sun, 24 Jan 2010 10:43:01 -0800, Dax Arroway
wrote:

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?

  #13   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

Hi Dax,

Please help me to help you. Reply to this thread with the following
information:

- The number and the exact and complete text of the error message.

- The entire code of the macro that has the error, copied from the VBA
editor and pasted into the newsgroup post.

- If the error message includes a Debug button, click it. That will
open the VBA editor and yellow-highlight the line where the error
occurred. In the code you include in the post, point to that line.

Even without that information, I'll take a quick guess at what's
wrong: The code you inserted refers to a string named Str1, but the
rest of your macro doesn't contain any string with that name. Change
Str1 to the name of the string that contains the text to be inserted
into the field. And put the three lines *after* the place in the macro
that assigns the text to that string.

To answer your other question, you need these three lines in *every*
macro that tries to assign a long (more than 255 characters) string to
a form field. Putting it into only one of those macros is not
sufficient.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sun, 24 Jan 2010 10:43:01 -0800, Dax Arroway
wrote:

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?

  #14   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

Awesome, yes please help. Obviously, you're right, I don't have a text
string named Str1 and the code is inserted in the wrong place. But I don't
know how to "name" my text either. Case "Level 0" in the code below is as
far as I got in inserting the text into the macro but it is mostly in Cell(3)
which all of the long text, including paragraph marks, will reside. I didn't
include the other macros (PPCDim1, PPCD2, PPC4, 5, or 6), because they
actually don't break the 255 character limit and work fine, and even if they
do, with what you give me here I'll be able to apply there if needed. If I'm
counting characters right, Cell(4) will also throw the "StringTooLong"
run-time error.

Here's my code:

Sub PPCDim3()
'
' PPCDim3 Macro
' Macro created 1/23/2010 by Dax
'
ActiveDocument.Unprotect
!!! Run-time Error '424': Object required !!! --
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 0"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/Lethality: Good impulse control and coping skills." & vbCr & _
"Interference with addiction recovery efforts: Emotional
concerns relate to negative consequences and effects of addiction. Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of social
functioning are being impaired but not endangered by patient's substance use.
Able to meet personal responsibilities and maintain stable meaningful
relationships despite the mild symptoms experienced." & vbCr & _
"Ability for self-ca Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and symptoms with
good response to treatment in the past. Any past serious problems have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Low-intensity mental health services needed to coordinate medication and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates specific
services for dual diagnosis patients as well as chemical dependency only
patients and mental health only patients."

Next i
Case "Level 1"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 1 in Column 4"
Next i
Case "Level 2"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 2 in Column 4"
Next i
Case "Level 3"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 3 in Column 4"
Next i
Case "Level 4"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 4 in Column 4"
Next i
End Select
End Sub

I hope that's enough help for you to help me. I really appreciate it.
Thank you SO MUCH!
--Dax
----------------------------------------
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

Hi Dax,

Please help me to help you. Reply to this thread with the following
information:

- The number and the exact and complete text of the error message.

- The entire code of the macro that has the error, copied from the VBA
editor and pasted into the newsgroup post.

- If the error message includes a Debug button, click it. That will
open the VBA editor and yellow-highlight the line where the error
occurred. In the code you include in the post, point to that line.

Even without that information, I'll take a quick guess at what's
wrong: The code you inserted refers to a string named Str1, but the
rest of your macro doesn't contain any string with that name. Change
Str1 to the name of the string that contains the text to be inserted
into the field. And put the three lines *after* the place in the macro
that assigns the text to that string.

To answer your other question, you need these three lines in *every*
macro that tries to assign a long (more than 255 characters) string to
a form field. Putting it into only one of those macros is not
sufficient.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sun, 24 Jan 2010 10:43:01 -0800, Dax Arroway
wrote:

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?

.

  #15   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings

OK, this makes more sense.

Think about the steps you need when you're inserting a string longer
than 255 characters in a form field, in plain English:

1. Assign the text to a string variable.
2. Unprotect the document.
3. Assign the string variable to the form field's result.
4. Reprotect the document.

You need to do those four steps, in that order, each time you insert a
long string. So the Case "Level 0" code becomes this (and note that I
declared the string variable LongString at the beginning of the macro,
which only needs to be done once; and I removed the "For i = 2 to 4"
loop because all that does is repeat the entire case three times):

Sub PPCDim3()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
' For i = 2 To 4 == get rid of this
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and coping skills." &
vbCr & _
"Interference with addiction recovery efforts:
Emotional
concerns relate to negative consequences and effects of addiction.
Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social
functioning are being impaired but not endangered by patient's
substance use.
Able to meet personal responsibilities and maintain stable meaningful
relationships despite the mild symptoms experienced." & vbCr & _
"Ability for self-ca Adequate resources and skills
to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with
good response to treatment in the past. Any past serious problems
have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to coordinate medication
and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates
specific
services for dual diagnosis patients as well as chemical dependency
only
patients and mental health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

' Next i == get rid of this

When you modify Case "Level 1" and the other cases, follow the same
pattern.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 24 Jan 2010 20:32:01 -0800, Dax Arroway
wrote:

Awesome, yes please help. Obviously, you're right, I don't have a text
string named Str1 and the code is inserted in the wrong place. But I don't
know how to "name" my text either. Case "Level 0" in the code below is as
far as I got in inserting the text into the macro but it is mostly in Cell(3)
which all of the long text, including paragraph marks, will reside. I didn't
include the other macros (PPCDim1, PPCD2, PPC4, 5, or 6), because they
actually don't break the 255 character limit and work fine, and even if they
do, with what you give me here I'll be able to apply there if needed. If I'm
counting characters right, Cell(4) will also throw the "StringTooLong"
run-time error.

Here's my code:

Sub PPCDim3()
'
' PPCDim3 Macro
' Macro created 1/23/2010 by Dax
'
ActiveDocument.Unprotect
!!! Run-time Error '424': Object required !!! --
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 0"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/Lethality: Good impulse control and coping skills." & vbCr & _
"Interference with addiction recovery efforts: Emotional
concerns relate to negative consequences and effects of addiction. Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of social
functioning are being impaired but not endangered by patient's substance use.
Able to meet personal responsibilities and maintain stable meaningful
relationships despite the mild symptoms experienced." & vbCr & _
"Ability for self-ca Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and symptoms with
good response to treatment in the past. Any past serious problems have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Low-intensity mental health services needed to coordinate medication and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates specific
services for dual diagnosis patients as well as chemical dependency only
patients and mental health only patients."

Next i
Case "Level 1"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 1 in Column 4"
Next i
Case "Level 2"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 2 in Column 4"
Next i
Case "Level 3"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 3 in Column 4"
Next i
Case "Level 4"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 4 in Column 4"
Next i
End Select
End Sub

I hope that's enough help for you to help me. I really appreciate it.
Thank you SO MUCH!
--Dax
----------------------------------------
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

Hi Dax,

Please help me to help you. Reply to this thread with the following
information:

- The number and the exact and complete text of the error message.

- The entire code of the macro that has the error, copied from the VBA
editor and pasted into the newsgroup post.

- If the error message includes a Debug button, click it. That will
open the VBA editor and yellow-highlight the line where the error
occurred. In the code you include in the post, point to that line.

Even without that information, I'll take a quick guess at what's
wrong: The code you inserted refers to a string named Str1, but the
rest of your macro doesn't contain any string with that name. Change
Str1 to the name of the string that contains the text to be inserted
into the field. And put the three lines *after* the place in the macro
that assigns the text to that string.

To answer your other question, you need these three lines in *every*
macro that tries to assign a long (more than 255 characters) string to
a form field. Putting it into only one of those macros is not
sufficient.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sun, 24 Jan 2010 10:43:01 -0800, Dax Arroway
wrote:

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?

.



  #16   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings


Thank you so much Jay, it's so close I can taste it! ...but she still
doesn't fly. I did as you instructed (and thank you very much for the
explaination in English! Makes total sense) getting rid of the i = 2 to 4
and Next i things (throughout all the macros!). Everything works (other
dropdowns in different rows, selections NOT Level 0 from the dropdown we're
working on, but when I select Level 0 from PCCDim3 I get a Run-time error
'4609' = String Too Long ...still. Clicking Debug highlights the
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = LongString line.

I'm not sure what to do at this point. Maybe more information from me? I'm
running WinXP and Word03. Does that matter? I live in Oregon and it's not
raining outside--maybe that's it. *smile* I don't want the end user to be
able to modify the text so I unchecked the fill-in enabled boxes in the form
fields throughout columns 2, 3, and 4. Non of the form fields have bookmark
names. any other information helpful? When I cut and pasted the code into
the VE I had to 'skootch' things around to get rid of all the red font colors
so everything is black now exept for "Case" and "True".

Here's the entire PCCDim3 Macro:

Sub PPCDim3 ()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult

Case "Level 0"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and coping
skills." & vbCr & _
"Interference with addiction recovery efforts: emotional
concerns relate to negative consequences and effects of addiction. Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of social
functioning are being impaired but not endangered by patient's substance use.
Able to meet personal responsibilities and maintain stable meaningful
relationships despite the mild symptoms experienced." & vbCr & _
"Ability for self-ca Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and symptoms with
good response to treatment in the past. Any past serious problems have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString ===Hightlighted Yellow
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

LongString = _
"Low-intensity mental health services needed to coordinate
medication and case management services corrdinated with addiction and mental
health psycoeducation. Level I outpatient services that incorporates
specific services for dual diagnosis patients as well as chemical dependency
only patients and mental health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Case "Level 1"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Adequate impulse control and coping skills to deal
with any thoughts of harm to self or others."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 1 in Column 4"

Case "Level 2"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Suicidal ideation or violent impulses which require
more than routine outpatient monitoring."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 2 in Column 4"

Case "Level 3"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Frequent impulses to harm self or others. Patient
is not imminently dangerous in a 24-hour setting. No longer experiencing
command hallucinations and is responding to medication but needs further
stabiliztation."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 3 in Column 4"

Case "Level 4"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Imminent risk of suicide; psychosis with
unpredictable, disorganized or violent behavior; or gross neglect of self
care."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 4 in Column 4"

End Select

End Sub
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

OK, this makes more sense.

Think about the steps you need when you're inserting a string longer
than 255 characters in a form field, in plain English:

1. Assign the text to a string variable.
2. Unprotect the document.
3. Assign the string variable to the form field's result.
4. Reprotect the document.

You need to do those four steps, in that order, each time you insert a
long string. So the Case "Level 0" code becomes this (and note that I
declared the string variable LongString at the beginning of the macro,
which only needs to be done once; and I removed the "For i = 2 to 4"
loop because all that does is repeat the entire case three times):

Sub PPCDim3()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
' For i = 2 To 4 == get rid of this
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and coping skills." &
vbCr & _
"Interference with addiction recovery efforts:
Emotional
concerns relate to negative consequences and effects of addiction.
Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social
functioning are being impaired but not endangered by patient's
substance use.
Able to meet personal responsibilities and maintain stable meaningful
relationships despite the mild symptoms experienced." & vbCr & _
"Ability for self-ca Adequate resources and skills
to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with
good response to treatment in the past. Any past serious problems
have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to coordinate medication
and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates
specific
services for dual diagnosis patients as well as chemical dependency
only
patients and mental health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

' Next i == get rid of this

When you modify Case "Level 1" and the other cases, follow the same
pattern.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 24 Jan 2010 20:32:01 -0800, Dax Arroway
wrote:

Awesome, yes please help. Obviously, you're right, I don't have a text
string named Str1 and the code is inserted in the wrong place. But I don't
know how to "name" my text either. Case "Level 0" in the code below is as
far as I got in inserting the text into the macro but it is mostly in Cell(3)
which all of the long text, including paragraph marks, will reside. I didn't
include the other macros (PPCDim1, PPCD2, PPC4, 5, or 6), because they
actually don't break the 255 character limit and work fine, and even if they
do, with what you give me here I'll be able to apply there if needed. If I'm
counting characters right, Cell(4) will also throw the "StringTooLong"
run-time error.

Here's my code:

Sub PPCDim3()
'
' PPCDim3 Macro
' Macro created 1/23/2010 by Dax
'
ActiveDocument.Unprotect
!!! Run-time Error '424': Object required !!! --
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 0"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/Lethality: Good impulse control and coping skills." & vbCr & _
"Interference with addiction recovery efforts: Emotional
concerns relate to negative consequences and effects of addiction. Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of social
functioning are being impaired but not endangered by patient's substance use.
Able to meet personal responsibilities and maintain stable meaningful
relationships despite the mild symptoms experienced." & vbCr & _
"Ability for self-ca Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and symptoms with
good response to treatment in the past. Any past serious problems have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Low-intensity mental health services needed to coordinate medication and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates specific
services for dual diagnosis patients as well as chemical dependency only
patients and mental health only patients."

Next i
Case "Level 1"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 1 in Column 4"
Next i
Case "Level 2"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 2 in Column 4"
Next i
Case "Level 3"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 3 in Column 4"
Next i
Case "Level 4"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult = "Risk
Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = "Long
string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult = "Result
for Level 4 in Column 4"
Next i
End Select
End Sub

I hope that's enough help for you to help me. I really appreciate it.
Thank you SO MUCH!
--Dax
----------------------------------------
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

Hi Dax,

Please help me to help you. Reply to this thread with the following
information:

- The number and the exact and complete text of the error message.

- The entire code of the macro that has the error, copied from the VBA
editor and pasted into the newsgroup post.

- If the error message includes a Debug button, click it. That will
open the VBA editor and yellow-highlight the line where the error
occurred. In the code you include in the post, point to that line.

Even without that information, I'll take a quick guess at what's
wrong: The code you inserted refers to a string named Str1, but the
rest of your macro doesn't contain any string with that name. Change
Str1 to the name of the string that contains the text to be inserted
into the field. And put the three lines *after* the place in the macro
that assigns the text to that string.

To answer your other question, you need these three lines in *every*
macro that tries to assign a long (more than 255 characters) string to
a form field. Putting it into only one of those macros is not
sufficient.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sun, 24 Jan 2010 10:43:01 -0800, Dax Arroway
wrote:

Hmmm. I think I hear what you're saying but my limited VBA knowledge
prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it below the
Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let you know
about my full project, I've got a table that's 4 columns by 6 rows. First
row has a dropdown in it with 5 choices. Each choice will populate columns 2
to 4 with different data--the text strings I'm including in the Macros. So
for each row (I'm not sure if this is the best practice or not) I'm using an
instance of the same code (w/different names and different text strings) to
get the results I need. Therefore, each dropdown menu throughout column 1
runs a different Macro (PCCDim1, PCCDim2, etc.). Which makes me woder if I
need to include this code in each instance of the different Macros or if it
only needs to be called once.

So, A) am I using the right code? B) Am I putting it in the right place?
And C) Should I only put it once or in all the Macros?
.

.

  #17   Report Post  
Posted to microsoft.public.word.docmanagement
Jay Freedman Jay Freedman is offline
external usenet poster
 
Posts: 9,854
Default Chariage Returns & Returns in Strings


You're right, you were very close. Unfortunately I misled you on a small but
crucial detail. Sorry to have caused such trouble.

When you're using the LongString, you have to assign it to

....Range.Fields(1).Result.Text

instead of

....Range.FormFields(1).Result

I've tested it, and it works.

I'm happy for you that it isn't raining in Oregon. I'm in Pennsylvania, and
we've just had 2" of rain in the last 15 hours. Not quite what my friends in
California had recently, but not nice.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Dax Arroway wrote:
Thank you so much Jay, it's so close I can taste it! ...but she still
doesn't fly. I did as you instructed (and thank you very much for the
explaination in English! Makes total sense) getting rid of the i =
2 to 4 and Next i things (throughout all the macros!). Everything
works (other dropdowns in different rows, selections NOT Level 0 from
the dropdown we're working on, but when I select Level 0 from PCCDim3
I get a Run-time error '4609' = String Too Long ...still. Clicking
Debug highlights the
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = LongString
line.

I'm not sure what to do at this point. Maybe more information from
me? I'm running WinXP and Word03. Does that matter? I live in
Oregon and it's not raining outside--maybe that's it. *smile* I
don't want the end user to be able to modify the text so I unchecked
the fill-in enabled boxes in the form fields throughout columns 2, 3,
and 4. Non of the form fields have bookmark names. any other
information helpful? When I cut and pasted the code into the VE I
had to 'skootch' things around to get rid of all the red font colors
so everything is black now exept for "Case" and "True".

Here's the entire PCCDim3 Macro:

Sub PPCDim3 ()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult

Case "Level 0"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and
coping skills." & vbCr & _
"Interference with addiction recovery efforts:
emotional concerns relate to negative consequences and effects of
addiction. Able to view these as part of addiction and recovery." &
vbCr & _ "Social functioning: Relationships or spheres
of social
functioning are being impaired but not endangered by patient's
substance use. Able to meet personal responsibilities and maintain
stable meaningful relationships despite the mild symptoms
experienced." & vbCr & _ "Ability for self-ca
Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with good response to treatment in the past. Any past
serious problems have a long period of stability or past problems are
chronic but do not pose high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString ===Hightlighted Yellow
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to
coordinate medication and case management services corrdinated with
addiction and mental health psycoeducation. Level I outpatient
services that incorporates specific services for dual diagnosis
patients as well as chemical dependency only patients and mental
health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString ActiveDocument.Protect
Type:=wdAllowOnlyFormFields, NoReset:=True

Case "Level 1"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Adequate impulse control and coping skills
to deal with any thoughts of harm to self or others."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 1 in Column 4"

Case "Level 2"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Suicidal ideation or violent impulses which
require more than routine outpatient monitoring."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 2 in Column 4"

Case "Level 3"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Frequent impulses to harm self or others.
Patient is not imminently dangerous in a 24-hour setting. No longer
experiencing command hallucinations and is responding to medication
but needs further stabiliztation."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 3 in Column 4"

Case "Level 4"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Imminent risk of suicide; psychosis with
unpredictable, disorganized or violent behavior; or gross neglect of
self care."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 4 in Column 4"

End Select

End Sub

OK, this makes more sense.

Think about the steps you need when you're inserting a string longer
than 255 characters in a form field, in plain English:

1. Assign the text to a string variable.
2. Unprotect the document.
3. Assign the string variable to the form field's result.
4. Reprotect the document.

You need to do those four steps, in that order, each time you insert
a long string. So the Case "Level 0" code becomes this (and note
that I declared the string variable LongString at the beginning of
the macro, which only needs to be done once; and I removed the "For
i = 2 to 4" loop because all that does is repeat the entire case
three times):

Sub PPCDim3()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
' For i = 2 To 4 == get rid of this
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and coping skills." &
vbCr & _
"Interference with addiction recovery efforts:
Emotional
concerns relate to negative consequences and effects of addiction.
Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social
functioning are being impaired but not endangered by patient's
substance use.
Able to meet personal responsibilities and maintain stable
meaningful relationships despite the mild symptoms experienced." &
vbCr & _ "Ability for self-ca Adequate resources
and skills
to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with
good response to treatment in the past. Any past serious problems
have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to coordinate medication
and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates
specific
services for dual diagnosis patients as well as chemical dependency
only
patients and mental health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

' Next i == get rid of this

When you modify Case "Level 1" and the other cases, follow the same
pattern.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 24 Jan 2010 20:32:01 -0800, Dax Arroway
wrote:

Awesome, yes please help. Obviously, you're right, I don't have a
text string named Str1 and the code is inserted in the wrong place.
But I don't know how to "name" my text either. Case "Level 0" in
the code below is as far as I got in inserting the text into the
macro but it is mostly in Cell(3) which all of the long text,
including paragraph marks, will reside. I didn't include the other
macros (PPCDim1, PPCD2, PPC4, 5, or 6), because they actually don't
break the 255 character limit and work fine, and even if they do,
with what you give me here I'll be able to apply there if needed.
If I'm counting characters right, Cell(4) will also throw the
"StringTooLong" run-time error.

Here's my code:

Sub PPCDim3()
'
' PPCDim3 Macro
' Macro created 1/23/2010 by Dax
'
ActiveDocument.Unprotect
!!! Run-time Error '424': Object required !!! --
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/Lethality: Good impulse control and coping skills."
& vbCr & _ "Interference with addiction recovery
efforts: Emotional
concerns relate to negative consequences and effects of addiction.
Able to view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social functioning are being impaired but not endangered by
patient's substance use. Able to meet personal responsibilities and
maintain stable meaningful relationships despite the mild symptoms
experienced." & vbCr & _ "Ability for self-ca
Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with good response to treatment in the past. Any past
serious problems have a long period of stability or past problems
are chronic but do not pose high-risk vulnerability."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Low-intensity mental health services needed to coordinate
medication and case management services corrdinated with addiction
and mental health psycoeducation. Level I outpatient services
that incorporates specific services for dual diagnosis patients as
well as chemical dependency only patients and mental health only
patients."

Next i
Case "Level 1"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Long string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 1 in Column 4"
Next i
Case "Level 2"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Long string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 2 in Column 4"
Next i
Case "Level 3"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Long string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 3 in Column 4"
Next i
Case "Level 4"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Long string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 4 in Column 4"
Next i
End Select
End Sub

I hope that's enough help for you to help me. I really appreciate
it.
Thank you SO MUCH!
--Dax
----------------------------------------
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

Hi Dax,

Please help me to help you. Reply to this thread with the following
information:

- The number and the exact and complete text of the error message.

- The entire code of the macro that has the error, copied from the
VBA editor and pasted into the newsgroup post.

- If the error message includes a Debug button, click it. That will
open the VBA editor and yellow-highlight the line where the error
occurred. In the code you include in the post, point to that line.

Even without that information, I'll take a quick guess at what's
wrong: The code you inserted refers to a string named Str1, but the
rest of your macro doesn't contain any string with that name.
Change Str1 to the name of the string that contains the text to be
inserted into the field. And put the three lines *after* the place
in the macro that assigns the text to that string.

To answer your other question, you need these three lines in
*every* macro that tries to assign a long (more than 255
characters) string to a form field. Putting it into only one of
those macros is not sufficient.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.


On Sun, 24 Jan 2010 10:43:01 -0800, Dax Arroway
wrote:

Hmmm. I think I hear what you're saying but my limited VBA
knowledge prevents me from making this work. I tried putting:

ActiveDocument.Unprotect
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

into the top of the code and it errors. I then tried putting it
below the Sub PCCDim1()
and the
Dim ddresult As String
but I got another error. I'm obviously doing something wrong.

Could you please tell me if I'm on the right path? And to let
you know about my full project, I've got a table that's 4 columns
by 6 rows. First row has a dropdown in it with 5 choices. Each
choice will populate columns 2 to 4 with different data--the text
strings I'm including in the Macros. So for each row (I'm not
sure if this is the best practice or not) I'm using an instance
of the same code (w/different names and different text strings)
to get the results I need. Therefore, each dropdown menu
throughout column 1 runs a different Macro (PCCDim1, PCCDim2,
etc.). Which makes me woder if I need to include this code in
each instance of the different Macros or if it only needs to be
called once.

So, A) am I using the right code? B) Am I putting it in the
right place? And C) Should I only put it once or in all the
Macros?
.

.



  #18   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

HALLELUHA!!! And the clouds part and the sun shines and birds sing from the
heavens! Thank you SO much! It works perfectly! I really, really
appreciate your time and stick-to-itiveness to this. Computer science is
"funny" sometimes as to how exact you have to be. A missing period here or
misplaced case can really mess with you. I'm just glad you're smart enought
to know where it was. Lord knows I'm not... but we're learning all the time!
Hope the weather is nicer to ya. Till next time, thanks a million!

--Dax
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

You're right, you were very close. Unfortunately I misled you on a small but
crucial detail. Sorry to have caused such trouble.

When you're using the LongString, you have to assign it to

....Range.Fields(1).Result.Text

instead of

....Range.FormFields(1).Result

I've tested it, and it works.

I'm happy for you that it isn't raining in Oregon. I'm in Pennsylvania, and
we've just had 2" of rain in the last 15 hours. Not quite what my friends in
California had recently, but not nice.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Dax Arroway wrote:
Thank you so much Jay, it's so close I can taste it! ...but she still
doesn't fly. I did as you instructed (and thank you very much for the
explaination in English! Makes total sense) getting rid of the i =
2 to 4 and Next i things (throughout all the macros!). Everything
works (other dropdowns in different rows, selections NOT Level 0 from
the dropdown we're working on, but when I select Level 0 from PCCDim3
I get a Run-time error '4609' = String Too Long ...still. Clicking
Debug highlights the
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = LongString
line.

I'm not sure what to do at this point. Maybe more information from
me? I'm running WinXP and Word03. Does that matter? I live in
Oregon and it's not raining outside--maybe that's it. *smile* I
don't want the end user to be able to modify the text so I unchecked
the fill-in enabled boxes in the form fields throughout columns 2, 3,
and 4. Non of the form fields have bookmark names. any other
information helpful? When I cut and pasted the code into the VE I
had to 'skootch' things around to get rid of all the red font colors
so everything is black now exept for "Case" and "True".

Here's the entire PCCDim3 Macro:

Sub PPCDim3 ()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult

Case "Level 0"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and
coping skills." & vbCr & _
"Interference with addiction recovery efforts:
emotional concerns relate to negative consequences and effects of
addiction. Able to view these as part of addiction and recovery." &
vbCr & _ "Social functioning: Relationships or spheres
of social
functioning are being impaired but not endangered by patient's
substance use. Able to meet personal responsibilities and maintain
stable meaningful relationships despite the mild symptoms
experienced." & vbCr & _ "Ability for self-ca
Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with good response to treatment in the past. Any past
serious problems have a long period of stability or past problems are
chronic but do not pose high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString ===Hightlighted Yellow
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to
coordinate medication and case management services corrdinated with
addiction and mental health psycoeducation. Level I outpatient
services that incorporates specific services for dual diagnosis
patients as well as chemical dependency only patients and mental
health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString ActiveDocument.Protect
Type:=wdAllowOnlyFormFields, NoReset:=True

Case "Level 1"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Adequate impulse control and coping skills
to deal with any thoughts of harm to self or others."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 1 in Column 4"

Case "Level 2"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Suicidal ideation or violent impulses which
require more than routine outpatient monitoring."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 2 in Column 4"

Case "Level 3"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Frequent impulses to harm self or others.
Patient is not imminently dangerous in a 24-hour setting. No longer
experiencing command hallucinations and is responding to medication
but needs further stabiliztation."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 3 in Column 4"

Case "Level 4"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Imminent risk of suicide; psychosis with
unpredictable, disorganized or violent behavior; or gross neglect of
self care."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 4 in Column 4"

End Select

End Sub

OK, this makes more sense.

Think about the steps you need when you're inserting a string longer
than 255 characters in a form field, in plain English:

1. Assign the text to a string variable.
2. Unprotect the document.
3. Assign the string variable to the form field's result.
4. Reprotect the document.

You need to do those four steps, in that order, each time you insert
a long string. So the Case "Level 0" code becomes this (and note
that I declared the string variable LongString at the beginning of
the macro, which only needs to be done once; and I removed the "For
i = 2 to 4" loop because all that does is repeat the entire case
three times):

Sub PPCDim3()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
' For i = 2 To 4 == get rid of this
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and coping skills." &
vbCr & _
"Interference with addiction recovery efforts:
Emotional
concerns relate to negative consequences and effects of addiction.
Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social
functioning are being impaired but not endangered by patient's
substance use.
Able to meet personal responsibilities and maintain stable
meaningful relationships despite the mild symptoms experienced." &
vbCr & _ "Ability for self-ca Adequate resources
and skills
to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with
good response to treatment in the past. Any past serious problems
have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to coordinate medication
and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates
specific
services for dual diagnosis patients as well as chemical dependency
only
patients and mental health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

' Next i == get rid of this

When you modify Case "Level 1" and the other cases, follow the same
pattern.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 24 Jan 2010 20:32:01 -0800, Dax Arroway
wrote:

Awesome, yes please help. Obviously, you're right, I don't have a
text string named Str1 and the code is inserted in the wrong place.
But I don't know how to "name" my text either. Case "Level 0" in
the code below is as far as I got in inserting the text into the
macro but it is mostly in Cell(3) which all of the long text,
including paragraph marks, will reside. I didn't include the other
macros (PPCDim1, PPCD2, PPC4, 5, or 6), because they actually don't
break the 255 character limit and work fine, and even if they do,
with what you give me here I'll be able to apply there if needed.
If I'm counting characters right, Cell(4) will also throw the
"StringTooLong" run-time error.

Here's my code:

Sub PPCDim3()
'
' PPCDim3 Macro
' Macro created 1/23/2010 by Dax
'
ActiveDocument.Unprotect
!!! Run-time Error '424': Object required !!! --
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/Lethality: Good impulse control and coping skills."
& vbCr & _ "Interference with addiction recovery
efforts: Emotional
concerns relate to negative consequences and effects of addiction.
Able to view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social functioning are being impaired but not endangered by
patient's substance use. Able to meet personal responsibilities and
maintain stable meaningful relationships despite the mild symptoms
experienced." & vbCr & _ "Ability for self-ca
Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with good response to treatment in the past. Any past
serious problems have a long period of stability or past problems
are chronic but do not pose high-risk vulnerability."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Low-intensity mental health services needed to coordinate
medication and case management services corrdinated with addiction
and mental health psycoeducation. Level I outpatient services
that incorporates specific services for dual diagnosis patients as
well as chemical dependency only patients and mental health only
patients."

Next i
Case "Level 1"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Long string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 1 in Column 4"
Next i
Case "Level 2"

  #19   Report Post  
Posted to microsoft.public.word.docmanagement
Dax Arroway Dax Arroway is offline
external usenet poster
 
Posts: 58
Default Chariage Returns & Returns in Strings

HALLELUHA!!! And the clouds part and the sun shines and birds sing from the
heavens! Thank you SO much! It works perfectly! I really, really
appreciate your time and stick-to-itiveness to this. Computer science is
"funny" sometimes as to how exact you have to be. A missing period here or
misplaced case can really mess with you. I'm just glad you're smart enought
to know where it was. Lord knows I'm not... but we're learning all the time!
Hope the weather is nicer to ya. Till next time, thanks a million!

--Dax
--
I would give my left hand to be ambidextrous!


"Jay Freedman" wrote:

You're right, you were very close. Unfortunately I misled you on a small but
crucial detail. Sorry to have caused such trouble.

When you're using the LongString, you have to assign it to

....Range.Fields(1).Result.Text

instead of

....Range.FormFields(1).Result

I've tested it, and it works.

I'm happy for you that it isn't raining in Oregon. I'm in Pennsylvania, and
we've just had 2" of rain in the last 15 hours. Not quite what my friends in
California had recently, but not nice.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the newsgroup so
all may benefit.

Dax Arroway wrote:
Thank you so much Jay, it's so close I can taste it! ...but she still
doesn't fly. I did as you instructed (and thank you very much for the
explaination in English! Makes total sense) getting rid of the i =
2 to 4 and Next i things (throughout all the macros!). Everything
works (other dropdowns in different rows, selections NOT Level 0 from
the dropdown we're working on, but when I select Level 0 from PCCDim3
I get a Run-time error '4609' = String Too Long ...still. Clicking
Debug highlights the
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult = LongString
line.

I'm not sure what to do at this point. Maybe more information from
me? I'm running WinXP and Word03. Does that matter? I live in
Oregon and it's not raining outside--maybe that's it. *smile* I
don't want the end user to be able to modify the text so I unchecked
the fill-in enabled boxes in the form fields throughout columns 2, 3,
and 4. Non of the form fields have bookmark names. any other
information helpful? When I cut and pasted the code into the VE I
had to 'skootch' things around to get rid of all the red font colors
so everything is black now exept for "Case" and "True".

Here's the entire PCCDim3 Macro:

Sub PPCDim3 ()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult

Case "Level 0"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and
coping skills." & vbCr & _
"Interference with addiction recovery efforts:
emotional concerns relate to negative consequences and effects of
addiction. Able to view these as part of addiction and recovery." &
vbCr & _ "Social functioning: Relationships or spheres
of social
functioning are being impaired but not endangered by patient's
substance use. Able to meet personal responsibilities and maintain
stable meaningful relationships despite the mild symptoms
experienced." & vbCr & _ "Ability for self-ca
Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with good response to treatment in the past. Any past
serious problems have a long period of stability or past problems are
chronic but do not pose high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString ===Hightlighted Yellow
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to
coordinate medication and case management services corrdinated with
addiction and mental health psycoeducation. Level I outpatient
services that incorporates specific services for dual diagnosis
patients as well as chemical dependency only patients and mental
health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString ActiveDocument.Protect
Type:=wdAllowOnlyFormFields, NoReset:=True

Case "Level 1"
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Adequate impulse control and coping skills
to deal with any thoughts of harm to self or others."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 1 in Column 4"

Case "Level 2"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 2"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Suicidal ideation or violent impulses which
require more than routine outpatient monitoring."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 2 in Column 4"

Case "Level 3"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 3"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Frequent impulses to harm self or others.
Patient is not imminently dangerous in a 24-hour setting. No longer
experiencing command hallucinations and is responding to medication
but needs further stabiliztation."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 3 in Column 4"

Case "Level 4"

Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 4"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/lethality: Imminent risk of suicide; psychosis with
unpredictable, disorganized or violent behavior; or gross neglect of
self care."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 4 in Column 4"

End Select

End Sub

OK, this makes more sense.

Think about the steps you need when you're inserting a string longer
than 255 characters in a form field, in plain English:

1. Assign the text to a string variable.
2. Unprotect the document.
3. Assign the string variable to the form field's result.
4. Reprotect the document.

You need to do those four steps, in that order, each time you insert
a long string. So the Case "Level 0" code becomes this (and note
that I declared the string variable LongString at the beginning of
the macro, which only needs to be done once; and I removed the "For
i = 2 to 4" loop because all that does is repeat the entire case
three times):

Sub PPCDim3()

Dim LongString As String
Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
' For i = 2 To 4 == get rid of this
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"

LongString = _
"Dangerousness/Lethality: Good impulse control and coping skills." &
vbCr & _
"Interference with addiction recovery efforts:
Emotional
concerns relate to negative consequences and effects of addiction.
Able to
view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social
functioning are being impaired but not endangered by patient's
substance use.
Able to meet personal responsibilities and maintain stable
meaningful relationships despite the mild symptoms experienced." &
vbCr & _ "Ability for self-ca Adequate resources
and skills
to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with
good response to treatment in the past. Any past serious problems
have a
long period of stability or past problems are chronic but do not pose
high-risk vulnerability."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

LongString = _
"Low-intensity mental health services needed to coordinate medication
and
case management services corrdinated with addiction and mental health
psycoeducation. Level I outpatient services that incorporates
specific
services for dual diagnosis patients as well as chemical dependency
only
patients and mental health only patients."

ActiveDocument.Unprotect
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
LongString
ActiveDocument.Protect Type:=wdAllowOnlyFormFields,
NoReset:=True

' Next i == get rid of this

When you modify Case "Level 1" and the other cases, follow the same
pattern.

--
Regards,
Jay Freedman
Microsoft Word MVP FAQ: http://word.mvps.org
Email cannot be acknowledged; please post all follow-ups to the
newsgroup so all may benefit.

On Sun, 24 Jan 2010 20:32:01 -0800, Dax Arroway
wrote:

Awesome, yes please help. Obviously, you're right, I don't have a
text string named Str1 and the code is inserted in the wrong place.
But I don't know how to "name" my text either. Case "Level 0" in
the code below is as far as I got in inserting the text into the
macro but it is mostly in Cell(3) which all of the long text,
including paragraph marks, will reside. I didn't include the other
macros (PPCDim1, PPCD2, PPC4, 5, or 6), because they actually don't
break the 255 character limit and work fine, and even if they do,
with what you give me here I'll be able to apply there if needed.
If I'm counting characters right, Cell(4) will also throw the
"StringTooLong" run-time error.

Here's my code:

Sub PPCDim3()
'
' PPCDim3 Macro
' Macro created 1/23/2010 by Dax
'
ActiveDocument.Unprotect
!!! Run-time Error '424': Object required !!! --
FmFld.Range.Fields(1).Result.Text = Str1
ActiveDocument.Protect Type:=wdAllowOnlyFormFields, NoReset:=True

Dim ddresult As String
ddresult = Selection.FormFields(1).Result
Select Case ddresult
Case "Level 0"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 0"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Dangerousness/Lethality: Good impulse control and coping skills."
& vbCr & _ "Interference with addiction recovery
efforts: Emotional
concerns relate to negative consequences and effects of addiction.
Able to view these as part of addiction and recovery." & vbCr & _
"Social functioning: Relationships or spheres of
social functioning are being impaired but not endangered by
patient's substance use. Able to meet personal responsibilities and
maintain stable meaningful relationships despite the mild symptoms
experienced." & vbCr & _ "Ability for self-ca
Adequate resources and skills to
cope with emotional and behavioral problems." & vbCr & _
"Course of illness: Mild to moderate signs and
symptoms with good response to treatment in the past. Any past
serious problems have a long period of stability or past problems
are chronic but do not pose high-risk vulnerability."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Low-intensity mental health services needed to coordinate
medication and case management services corrdinated with addiction
and mental health psycoeducation. Level I outpatient services
that incorporates specific services for dual diagnosis patients as
well as chemical dependency only patients and mental health only
patients."

Next i
Case "Level 1"
For i = 2 To 4
Selection.Rows(1).Cells(2).Range.FormFields(1).Res ult =
"Risk Rating 1"
Selection.Rows(1).Cells(3).Range.FormFields(1).Res ult =
"Long string goes here."
Selection.Rows(1).Cells(4).Range.FormFields(1).Res ult =
"Result for Level 1 in Column 4"
Next i
Case "Level 2"

Reply
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Is it possible to replace soft returns with hard returns? rgmcfadden Microsoft Word Help 2 October 8th 08 03:51 PM
Carriage Returns suncobra9 Microsoft Word Help 1 August 3rd 08 11:00 PM
Replace all soft returns with hard returns Style-tamer Microsoft Word Help 2 January 31st 07 11:09 PM
Returns in Headers Adam Microsoft Word Help 1 March 22nd 06 02:39 PM
Carriage returns and XML Jorge Microsoft Word Help 1 June 30th 05 05:10 PM


All times are GMT +1. The time now is 06:10 PM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"