The information in this article applies to:
SUMMARY
In Microsoft Word for Windows version 2.x, you can use the Microsoft
Windows WritePrivateProfileString call within a WordBasic macro to
write to an .INI file other than the WIN.INI file.
Word for Windows 6.0, 7.0WARNING: ANY USE BY YOU OF THE MACRO CODE PROVIDED IN THIS ARTICLE IS AT YOUR OWN RISK. Microsoft provides this macro code "as is" 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.The following is an example for SetPrivateProfileString.
The above macro writes out the following information to the TEXT.INI file
in the C:\WINWORD directory:
The SetPrivateProfileString function copies a character string into
the specified section of the specified initialization file. The return
value is TRUE (1) if the function is successful or FALSE (0) if an
error occurs.
Word for Windows 2.xUsing Windows calls to read and write to a private text file is an alternative to the following standard WordBasic file input/output statements and functions:
According to the Microsoft Windows Software Development Kit
documentation, the WritePrivateProfileString function has the
following parameters:
The following WordBasic macro demonstrates the use of the Windows
WritePrivateProfileString function:
The above WordBasic macro writes out the following information to the
TEXT.INI file in the C:\WINWORD directory:
The WritePrivateProfileString function copies a character string into
the specified section of the specified initialization file. The return
value is TRUE (1) if the function is successful or FALSE (0) if an
error occurs.
If the FileName parameter does not contain a fully-qualified path for the file, this function searches the Windows directory for the file. If the file does not exist, this function creates the file in the WINDOWS directory. If FileName parameter contains a fully-qualified path and the file does not exist, this function creates the file. The specified directory must already exist. Note: To add a string to the WIN.INI file use the WordBasic "SetProfileString" function. For information about how to do this in Word 97, please see the following article(s) in the Microsoft Knowledge Base: Q160132 Sample VB Code to Set, Retrieve Ini, Registry Settings REFERENCESMicrosoft Windows Software Development Kit, Vol. 1, page 4-462 through page 4-464 Additional query words: GetPrivateProfileString 2.0 winword2 word7 word6 winword 7.0 word95 ntword wordnt
Keywords : |
Last Reviewed: September 24, 1999 © 2000 Microsoft Corporation. All rights reserved. Terms of Use. |