WD6X: GetProfileString() Returns Invalid Path

Last reviewed: February 3, 1998
Article ID: Q118834
The information in this article applies to:
  • Microsoft Word for the Macintosh, version 6.0

SYMPTOMS

Using the GetProfileString$() function to return a path setting in the Word Settings (6) file results in a path that contains "garbage" (corrupted) characters or symbols. For example, the following sample macro, which retrieves the path setting for the Templates directory, returns garbage text:

   Sub MAIN
      a$=GetProfileString$("Microsoft Word", "USER-DOT-PATH")
      MsgBox a$
   End Sub

Note that the GetProfileString$() function does not require a file name or path argument for the Word Settings (6) file after "USER-DOT-PATH". WordBasic defaults to the Word Settings (6) file in the Preferences folder.

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/ 

CAUSE

When retrieving predefined file path settings in the Microsoft Word section of the Word Settings (6) file, Word makes a second call to the settings file, and the incorrect information is returned. The problem, which occurs when reading the Word Settings (6) file when using the GetProfileString$() function, is a known problem.

RESOLUTION

To avoid returning unusable information, use the GetPrivateProfileString$() function. The GetPrivateProfileString$() function returns a setting in a settings file that you specify, for example:

   Sub MAIN
      a$=GetPrivateProfileString$("Microsoft Word", "USER-DOT-PATH", \
      "Word Settings (6)")
      MsgBox a$
   End Sub

Note that the GetPrivateProfileString$() function requires that you specify settings file name. In this case it is "Word Settings (6)." When retrieving values from the Word Settings (6) file with the GetPrivateProfileString$() function, do not specify a path for the Word Settings (6) parameter because this path defaults to the Preferences folder in the System folder.

MORE INFORMATION

Predefined file path settings in the Microsoft Word section of the Word Settings (6) file are those that are set in the File Locations tab. (To locate this option, click Options on the Tools menu.) Settings other than "User Options" can only be returned by macro functions if they are first set in the File Locations tab.


Additional query words: code null string folder default file location macro
Keywords : kbmacroexample macword word6 kbcode kbmacro kbprg
Version : MACINTOSH:6.0,6.0.1,6.0.1a
Platform : MACINTOSH
Issue type : kbbug
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 3, 1998
© 1998 Microsoft Corporation. All rights reserved. Terms of Use.