SetProfileString

Syntax

SetProfileString Section$, KeyName$, Setting$

Remarks

In Windows, creates a key and defines a setting for it, or redefines the setting of an existing key in WIN.INI. If Section$ is "Microsoft Word 2.0," "Microsoft Word," "MSWord Text Converters," or "MSWord Editable Sections," SetProfileString redefines the setting in WINWORD6.INI. These exceptions are made for compatibility with Word for Windows version 2.x macros. On the Macintosh, SetProfileString defines settings in the Word Settings (6) file. It is generally preferable to use SetPrivateProfileString, which allows you to specify a settings file to modify.

Argument

Explanation

Section$

The name of the section in the settings file that contains the key you want to set. In Windows, this is the name that appears between brackets before the associated keys (do not include the brackets with Section$).

KeyName$

The key to set. In Windows, the key name is followed by an equal sign (=) and the setting.

Setting$

The new setting.


Note

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.

Example

This Windows example uses GetSystemInfo$() to determine the "sCountry" setting in the [intl] section of WIN.INI; SetProfileString changes the key's setting to "Sweden" if it does not already have that setting.


If GetSystemInfo$(29) <> "Sweden" Then
    SetProfileString "intl", "sCountry", "Sweden"
End If

See Also

GetPrivateProfileString$(), GetProfileString$(), SetPrivateProfileString, ToolsAdvancedSettings