PrivateProfileString Property Example

This example sets the current document name as the LastFile setting under the MacroSettings heading in Settings.txt.

System.PrivateProfileString("C:\Settings.txt", "MacroSettings", _
    "LastFile") = ActiveDocument.FullName

This example returns the LastFile setting from Settings.txt and then opens the document stored in LastFile.

LastFile = System.PrivateProfileString("C:\Settings.Txt", _
    "MacroSettings", "LastFile")
If LastFile <> "" Then Documents.Open FileName:=LastFile

This example displays the value of the EmailName entry from the Windows registry.

aName = System.PrivateProfileString("", _
    "HKEY_CURRENT_USER\Software\Microsoft\" _
    & "Windows\CurrentVersion\Internet Settings", "EmailName")
MsgBox aName