Share via

Error 4609 'String too long'. Received when using Word automation from Access (2K3) to insert a formfield value in a Word document.

Anonymous
2010-02-09T22:31:35+00:00

The Access field is a memo. The Word form field is limited to 1000 characters (hence the need for the memo field in the Access database). Interestingly enough, as long as I only insert a max of 255 characters I get no error. Even more stunning is that there is no error in processing the document to retrieve data filled in by a user, i.e., if the user enters 472 characters (for example) then all of that can be pull from the formfield.Result and properly placed in the database memo field. The problem occurs if I attempt to regenerate the document with more than 255 characters of data in the memo field.

Any help would be most appreciated!!! James

PS - this may not be posted in the proper place ... but it seemed to be the best fit based on the selectable topics.

Microsoft 365 and Office | Word | For home | Windows

Locked Question. This question was migrated from the Microsoft Support Community. You can vote on whether it's helpful, but you can't add comments or replies or follow the question.

0 comments No comments

Answer accepted by question author

Jay Freedman 207.7K Reputation points Volunteer Moderator
2010-02-10T04:34:20+00:00

It's an old and very annoying bug in VBA. See here for a workaround.


Jay Freedman MS Word MVP

Was this answer helpful?

0 comments No comments

4 additional answers

Sort by: Most helpful
  1. Doug Robbins - MVP - Office Apps and Services 323.1K Reputation points MVP Volunteer Moderator
    2010-07-24T01:05:19+00:00

    Use

    Dim docprot As Boolean

    With ActiveDocument

        If .ProtectionType <> wdNoProtection Then

            blnprot = True

            .Unprotect

        Else

            blnprot = False

        End If

        .Bookmarks("Text1").Range.Fields(1).Result.Text = Str1

        If blnprot = True Then

            .Protect Type:=wdAllowOnlyFormFields, NoReset:=True

        End If

    End With

    -- Hope this helps.

    Doug Robbins - Word MVP,

    dkr[atsymbol]mvps[dot]org

    Posted via the Community Bridge

    "threni" wrote in message news:*** Email address is removed for privacy ***...

    May I ask what to do when this solution causes another error to the effect that the document is already unprotected?


    Doug Robbins - Word MVP dkr[atsymbol]mvps[dot]org

    Was this answer helpful?

    0 comments No comments
  2. Anonymous
    2010-07-23T23:25:43+00:00

    May I ask what to do when this solution causes another error to the effect that the document is already unprotected?

    Was this answer helpful?

    0 comments No comments
  3. Anonymous
    2010-06-02T13:23:05+00:00

    Woooooow, many thanks to both of you, I thought I would become crazy with this odd issue.

    Had the same issue with word automation though a C# windows application.

    This does not work:

    newDoc.FormFields.get_Item(ref field).Result = strValue;

    This works:

    newDoc.FormFields.get_Item(ref field).Range.Fields[1].Result.Text = strValue;

    Thanks !!!

    Was this answer helpful?

    0 comments No comments
  4. Anonymous
    2010-02-10T04:41:37+00:00

    Thank you Jay. I was just coming back here to put a note that I had found a solution from a different source. I'm not sure why I didn't find it when doing my initial search (which prompted me to post this question). The link you provided was much more succinct and informative and would have saved me quite a bit of time! Many thanks again... James

    Was this answer helpful?

    0 comments No comments