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 / June 2007

Tip: Looking for answers? Try searching our database.

FormFields(1).Result - maximum 255 characters

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Fred - 26 Jun 2007 23:33 GMT
I am trying to fill in a form while the form remains locked and protected.
Manually I can type as much information as I like into one of the formfields
but when I try to use FormFields(1).result = myString then I get an error
"string too long" whenever the string is more than 255 characters.

Can some please tell me how I can get more than 255 characters in to the
formfield without unlocking the form. The must remain locked and protected.

Thanks
Fred
David Sisson - 27 Jun 2007 00:30 GMT
Hi Fred,

Here ya go.

http://word.mvps.org/faqs/macrosvba/SetLongFmFldResult.htm
Fred - 27 Jun 2007 00:56 GMT
Thanks David but that simply unprotects the document. I can't unprotect the
document as it is password protected and do not have the password.

> Hi Fred,
>
> Here ya go.
>
> http://word.mvps.org/faqs/macrosvba/SetLongFmFldResult.htm
David Sisson - 27 Jun 2007 02:17 GMT
Sorry, Fred, I read right over that last part.

I'm afraid you're out of luck unless someone else has another idea.
David Sisson - 27 Jun 2007 14:23 GMT
Hey Fred,

I found this workaround.  It's not pretty and may require manual
intervention, but it gets more than 255 characters in the formfield.
It allows you to edit the field after the macro runs, too.

Sub Insert255Plus
Dim MyString As String
Dim HalfLength As Integer
Dim Half1 As String
Dim Half2 As String

HalfLength = Len(MyString) / 2
Half1 = Left(MyString, HalfLength)
Half2 = Right(MyString, Len(MyString) - HalfLength)

AutoCorrect.Entries.Add Name:="Half1", Value:=Half1
AutoCorrect.Entries.Add Name:="Half2", Value:=Half2

ActiveDocument.FormFields(1).Result = "Half1 Half2"

End Sub

The catch is that the autocorrect entry can't be more than 255
characters.  That's why I split the string in two lengths

Hope this helps,
David
Fred - 27 Jun 2007 23:02 GMT
Hi David,

thanks for the idea but I can't get it to autocorrect on its own. For it to
work I need to manually go into the document and enter a space after the
autocorrect field name ("Half1").
Is there someway of programmatically forcing word to apply the
autocorrection.?

Fred

> Hey Fred,
>
[quoted text clipped - 24 lines]
> Hope this helps,
> David
Russ - 30 Jun 2007 02:11 GMT
Fred,
Using =rand(22,22)<ENTER>, I generated over 17,000 characters that I was
able to create an AutoText entry for and AutoText insert into a new blank
document.
Look in VBA help for creating, inserting, deleting AutoText entries.
The code is similar to what David used for AutoCorrect since they are close
cousins code-wise.
> Hi David,
>
[quoted text clipped - 34 lines]
>> Hope this helps,
>> David

Signature

Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Rate this thread:






 
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.