Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / March 2007

Tip: Looking for answers? Try searching our database.

Text Formfields?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
jille - 05 Mar 2007 19:15 GMT
Hi,

I've created a userform with a textbox that allows the user to enter
multiple lines of text and use the Enter key to add additional paragraphs.

I'm trying to move this text to a text formfield but it's pulling out the
hard carriage returns. I know that if the user was filling out the formfield
directly, they would be able to use the Enter key within the field.

I've already tested the code to ensure that it works, for example, when I
use a simple bookmark (instead of the formfield) and it does. The obvious
solution is to use a bookmark but this option isn't viable due to other
issues.

Any suggestions on getting the text formfield to recognize the hard carriage
return?

Really desperate for an answer so any thoughts would be most appreciated.

Thanks,
Jille
Jay Freedman - 06 Mar 2007 02:22 GMT
I have some questions about what you've done and what you're seeing,
because your description doesn't match my experience.

- Is the textbox in the userform set to MultiLine = True and
EnterKeyBehavior = True?

- Is the code in your userform something like this?

  ActiveDocument.FormFields("Text1").Result = TextBox1.Text

- Do you really see a single long line in the form field where you
expect to see several lines?

When I set up a userform as I indicated in the first two items, the
form field shows multiple lines, but each line starts with a square.
That's because the return in the userform's textbox consists of two
characters, Chr(13) & Chr(10), while a return in the form field is
only the Chr(13). The Chr(10) appears as the box. The solution for
that is to write the line of code as

  ActiveDocument.FormFields("Text1").Result = _
     Replace(TextBox1.Text, Chr(10), "")

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

>Hi,
>
[quoted text clipped - 17 lines]
>Thanks,
>Jille
jille - 06 Mar 2007 13:33 GMT
Hi Jay,

Yes to all questions and I did get the squares instead of hard carriage
return but I didn't know what it meant.

You identified the exact problem...

Thanks for your help,

Jille

> I have some questions about what you've done and what you're seeing,
> because your description doesn't match my experience.
[quoted text clipped - 47 lines]
> >Thanks,
> >Jille
jille - 06 Mar 2007 13:59 GMT
I should clarify....

I am getting two small boxes where a single hard carriage should appear.
When I try the code you suggest I get one box instead of two. So I replaced
both the Chr(10) & 13 and determined that they were both being represented as
a small box. Now how do I add a hard carriage in?

FYI, I'm using Word 2000!

> I have some questions about what you've done and what you're seeing,
> because your description doesn't match my experience.
[quoted text clipped - 47 lines]
> >Thanks,
> >Jille
Jay Freedman - 06 Mar 2007 15:03 GMT
That's just plain weird. The Chr(13) should become a paragraph mark inside
the text formfield.

You could try this in your code:

  Dim temp As String
  temp = TextBox1.Text
  temp = Replace(temp, Chr(10), "")
  temp = Replace(temp, Chr(13), vbCr)
  ActiveDocument.FormFields("Text1").Result = temp

The built-in value vbCr is really just a constant that represents a carriage
return (paragraph mark), but maybe forcing the replacement will make Word
happy. If that doesn't work, I'm out of tricks for now.

Signature

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.

> I should clarify....
>
[quoted text clipped - 60 lines]
>>> Thanks,
>>> Jille
jille - 06 Mar 2007 15:33 GMT
Hi Jay,

The vbcr didn't work. I ended up pulling the boxes out using your replace
strings but replaced one with a tilde so that I could do a search & replace
once the text was in the form. It's awkward but I'm happy its solved!.

Thanks for all your help.

Jill

> That's just plain weird. The Chr(13) should become a paragraph mark inside
> the text formfield.
[quoted text clipped - 75 lines]
> >>> Thanks,
> >>> Jille
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.