VBScript program demonstrating how to write information to a Microsoft Excel spreadsheet. The program binds to a user object in Active Directory and writes a few attribute values to cells in the spreadsheet. The program includes a loop to enumerate the groups the user is a member of and writes the group names to the spreadsheet. A few cells are formatted and the spreadsheet is saved. The name of the spreadsheet is passed to the program as an argument. If the file name of the spreadsheet does not include a path, the spreadsheet is assumed to be in the current directory, which is most likely the folder the program is in. The program checks to make sure that Microsoft Excel is installed. When the spreadsheet is saved, if the file already exists, Excel asks the user if the file should be overwritten.

The program has been revised to use an optional parameter of the SaveAs method of the ActiveWorkgroup object that specifies the File Format. A value is specified that results in a file that can be saved and read by either Excel 2003 or Excel 2007. Without this parameter, files saved by Excel 2007 cannot later be read by Excel 2003.

XLWrite.txt <<-- Click here to view or download the program