FormFields(1).Result - maximum 255 characters

F

Fred

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
 
F

Fred

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

David Sisson

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

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

David Sisson

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
 
F

Fred

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
 
R

Russ

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top