Excel VBA Script for File Management
Excel VBA Script for File Management
The script uses Word's Application object to create a new document and add a table with three columns. It queries the Win32_Service class to retrieve services' names, display names, and states. It writes these details into the table, adding a bold font for the first column, and iteratively adds rows to accommodate each service .
The script opens the Excel file and accesses the worksheet. It determines the used range and iterates over each cell, retrieving the 'interior.colorindex' property for each cell, which provides the background color index of the cell. The result is displayed in a message box .
The script uses the Word Application's 'FileSearch' method to search for Word documents ('*.doc') across all system drives. It sets the 'LookIn' property to each drive and enables 'SearchSubFolders'. It then executes a search and iterates over found files, displaying their names, sizes, and creation dates .
The script creates a description object for web checkboxes by setting the 'micclass' property to "WebCheckBox". It then retrieves all child objects that match this description within the Yahoo Mail inbox and iteratively sets the 'ON' state for the first ten checkboxes using a loop .
The script defines a 'SendMail' function using the Outlook Application object. It creates a new mail item, sets the recipient, subject, and body from the parameters passed to the function. If an attachment is specified, it adds it to the mail. Finally, the mail is sent using 'm.Send' and the Outlook Application is quit .
The script uses the 'Saveas' method of the Excel Workbook object to apply read and write protection to an Excel file. It passes two password parameters, 'pwd1' for read protection and 'pwd2' for write protection, as part of the Saveas method call .
The script opens an existing Excel file using 'CreateObject' for the Excel Application and 'Workbooks.Open'. It accesses 'sheet1' and assigns values to specific cells in the second column directly by setting the 'cells' properties with new text values. After writing, the workbook is saved and closed .
The script interacts with Microsoft Word to check for spelling errors. It uses the 'WordBasic.insert' method to add the text of each link into a new Word document. If the document contains any spelling errors, identified via 'ActiveDocument.Spellingerrors.count', a report is generated with the details of the misspelled words .
The script opens an Excel file using 'CreateObject' for the Excel Application and 'Workbooks.Open'. It accesses the worksheet 'sheet1' and calculates the used range of rows and columns. A nested loop then reads and concatenates the values cell by cell, printing each row's values before moving to the next row .
The script employs 'CreateObject' to instantiate the Internet Explorer Application. It sets the 'Visible' property to True to make the browser window visible and uses the 'Navigate' method to open the Yahoo Mail webpage .