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

Re: FormFields(1).Result - maximum 255 characters by David

David
Tue Jun 26 18:30:38 CDT 2007

Hi Fred,

Here ya go.

http://word.mvps.org/faqs/macrosvba/SetLongFmFldResult.htm


Re: FormFields(1).Result - maximum 255 characters by Fred

Fred
Tue Jun 26 18:56:02 CDT 2007

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.


"David Sisson" <Tinbendr@gmail.com> wrote in message
news:1182900638.397043.153990@g4g2000hsf.googlegroups.com...
> Hi Fred,
>
> Here ya go.
>
> http://word.mvps.org/faqs/macrosvba/SetLongFmFldResult.htm
>



Re: FormFields(1).Result - maximum 255 characters by David

David
Tue Jun 26 20:17:07 CDT 2007

Sorry, Fred, I read right over that last part.

I'm afraid you're out of luck unless someone else has another idea.


Re: FormFields(1).Result - maximum 255 characters by David

David
Wed Jun 27 08:23:49 CDT 2007

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


Re: FormFields(1).Result - maximum 255 characters by Fred

Fred
Wed Jun 27 17:02:31 CDT 2007

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


"David Sisson" <Tinbendr@gmail.com> wrote in message
news:1182950629.881056.237600@k29g2000hsd.googlegroups.com...
> 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
>



Re: FormFields(1).Result - maximum 255 characters by Russ

Russ
Fri Jun 29 20:11:32 CDT 2007

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,
>
> 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
>
>
> "David Sisson" <Tinbendr@gmail.com> wrote in message
> news:1182950629.881056.237600@k29g2000hsd.googlegroups.com...
>> 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
>>
>
>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID