Microsoft KB Archive/98835

{|
 * width="100%"|

Using SetProfileString Statement to Set Values in WIN.INI File

 * }

Q98835

-

The information in this article applies to:


 * Microsoft Word for Windows, versions 1.0, 1.1, 1.1a, 2.0, 2.0a, 2.0a-CD, 2.0b, 2.0c, 6.0, 6.0a, 6.0c
 * Microsoft Word for Windows, versions 7.0, 7.0a

-

SUMMARY
This article describes how to use the WordBasic SetProfileString statement in Word for Windows to add to or modify information in the Windows WIN.INI file. This article also describes a limitation of the SetProfileString statement in which you cannot store a line break character in the .Value argument.

Below are macros that demonstrate the use of the SetProfileString statement to set values in your WIN.INI file.

Word for Windows, Versions 6.0, 7.0, 7.0a
In the following macro, the proof path under the [MSAPPS] heading is changed to C:\WINDOWS\MSAPPS\PROOF.

 Sub MAIN SetProfileString &quot;MSAPPS&quot;, &quot;PROOF&quot;, &quot;C:\WINDOWS\MSAPPS\PROOF&quot; End Sub In Windows 95 and Windows NT, settings are stored in the registry. You can still use SetProfileString and GetProfileString$ to set and return settings from a text file with the name WIN.INI, but neither the system nor Word uses these settings. To access and change values in the registry from within WordBasic, you need to use GetPrivateProfileString$ and SetPrivateProfileString.

Word for Windows, Versions 6.x
Word 6.0 for Windows stores most of the Word specific settings in the WINWORD6.INI file. This file is located in your \Windows directory. Using the SetPrivateProfileString statement, you can write to the WINWORD6.INI file.

 Sub MAIN SetPrivateProfileString &quot;Microsoft Word&quot;, &quot;INI-path&quot;, \ &quot;D:\WINWORD&quot;, &quot;C:\WINDOWS\WINWORD6.INI&quot; End Sub If you are using Word 2.x for Windows, you can use the Microsoft Windows WritePrivateProfileString command in a WordBasic macro to write to an .INI file other than the WIN.INI file. For more information, query on the following words in the Microsoft Knowledge Base:

"private and text and file and windows and calls" WARNING: ANY USE BY YOU OF THE CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code &quot;as is&quot; without warranty of any kind, either express or implied, including but not limited to the implied warranties of merchantability and/or fitness for a particular purpose.

SetProfileString Truncates at Line Break Character
You cannot store a line break character or any text that follows the line break in the .Value argument of the SetProfileString statement. If you assign a string to the .Value argument that contains two or more lines, separated by a line break character, SetProfileString stores only the portion of the string that precedes the first line break character.

Word for Windows, Versions 2.x
In the following macro, if a DOC-path statement is present in the [Microsoft Word 2.0] section of your WIN.INI file, the DOC-path will be changed to C:\WINWORD:

 Sub MAIN SetProfileString &quot;Microsoft Word 2.0&quot;, &quot;DOC-path&quot;, &quot;C:\WINWORD&quot; End Sub

Word for Windows, Version 1.x
The macro below sets the directory for the WINWORD.INI file to C:\WINWORD. If an INI-path statement is present in the [Microsoft Word] section of your WIN.INI file, the INI-path will be changed to C:\WINWORD.

 Sub MAIN SetProfileString &quot;Microsoft Word&quot;, &quot;INI-path&quot;, &quot;C:\WINWORD&quot; End Sub

Word 97
For information about how to do this in Word 97, while in the Visual Basic for Applications Editor click the Office Assistant, type PrivateProfileString, click Search, and then click to view &quot;PrivateProfileString Property.&quot; To view examples, point to Example.

NOTE: If the Assistant is hidden, click the Office Assistant button on the Standard toolbar. If Microsoft Help is not installed on your computer, please see the following article in the Microsoft Knowledge Base:

"Q120802 Office: How to Add/Remove a Single Office Program or Component"