WD: GetFormResult$() Function Returns Incomplete Text String

Last reviewed: February 12, 1998
Article ID: Q127743
The information in this article applies to:
  • Microsoft Word for Windows, versions 6.0, 6.0a, 6.0c
  • Microsoft Word for Windows NT, version 6.0
  • Microsoft Word for Windows 95, versions 7.0 7.0a
  • Microsoft Word for the Macintosh, versions 6.0, 6.0.1, 6.0.1a

SYMPTOMS

When you use the WordBasic function GetFormResult$() to return the text of a text form field (with a length set to Unlimited), the function returns only the first 255 characters of that text string.

CAUSE

In Word 7.x and earlier, the maximum size of the return string of GetFormResult$() and SetFormResult is 255 characters.

In Microsoft Word 97 for Windows and Word 98 Macintosh Edition, the maximum size is 65,279 characters.

RESOLUTION

Microsoft provides programming examples for illustration only, without warranty either expressed or implied, including, but not limited to, the implied warranties of merchantability and/or fitness for a particular purpose. This article assumes that you are familiar with the programming language being demonstrated and the tools used to create and debug procedures. Microsoft support engineers can help explain the functionality of a particular procedure, but they will not modify these examples to provide added functionality or construct procedures to meet your specific needs. If you have limited programming experience, you may want to contact the Microsoft fee-based consulting line at (800) 936-5200. For more information about the support options available from Microsoft, please see the following page on the World Wide Web:

   http://www.microsoft.com/supportnet/refguide/ 

GetBookmark$():

To retrieve the full text string, use the GetBookmark$() function. GetBookmark$() returns the full text string and a form field header containing the field of origin. To return the text string alone, the macro must strip off the header.

The following sample macro returns the entire contents of a text form field using the GetBookmark$() function:

   Sub MAIN
      ' Sets contents of form field Text1 to a$.
      a$ = GetBookmark$("Text1")      
      ' Strips off the form field header.
      a$ = Mid$ (a$, 10)
      ' Unprotects the active document.
      ToolsUnprotectDocument
      ' Moves the insertion point down 1 line.
      LineDown
      ' Inserts form field contents into the document.
      Insert a$
      ' Reprotects document without resetting form
      ' field values back to defaults.
      ToolsProtectDocument .NoReset=1
   End Sub

SetFormResult:

To work around the problem with SetFromResult, use the following sample macro:

   Sub MAIN
      a$ = InputBox$("Type more than 255 characters")
      ' Goto the form field's bookmark name.
      EditGoTo "Text1"
      ' Unprotect the active document.
      ToolsUnprotectDocument
      Insert a$
      ' Reprotects document without resetting form
      ' field values back to defaults.
      ToolsProtectDocument .NoReset = 1
   End Sub


Additional query words: formfields limits getformresult
Keywords : kbmacroexample macword ntword win95 winword word6 word7 word95 wordnt kbcode
Version : WINDOWS:6.0,6.0a,6.0c,7.0,7.0a; MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH Win95 WINDOWS winnt
Issue type : kbprb
Solution Type : kbworkaround


THE INFORMATION PROVIDED IN THE MICROSOFT KNOWLEDGE BASE IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND. MICROSOFT DISCLAIMS ALL WARRANTIES, EITHER EXPRESS OR IMPLIED, INCLUDING THE WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE. IN NO EVENT SHALL MICROSOFT CORPORATION OR ITS SUPPLIERS BE LIABLE FOR ANY DAMAGES WHATSOEVER INCLUDING DIRECT, INDIRECT, INCIDENTAL, CONSEQUENTIAL, LOSS OF BUSINESS PROFITS OR SPECIAL DAMAGES, EVEN IF MICROSOFT CORPORATION OR ITS SUPPLIERS HAVE BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES. SOME STATES DO NOT ALLOW THE EXCLUSION OR LIMITATION OF LIABILITY FOR CONSEQUENTIAL OR INCIDENTAL DAMAGES SO THE FOREGOING LIMITATION MAY NOT APPLY.

Last reviewed: February 12, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.