Microsoft Office Tutorials and References
In Depth Information Quit method
The Select method does not add the current selection to the PreviousSelections array.
The Select method has a Replace argument. Quit method
This method closes Excel. Note that the BeforeClose event will fire when the Quit method is
executed. (This event has a Cancel parameter that can be set to cancel the quit operation.) We
discussed workbook events (including BeforeClose) in Chapter 11 .
Note that if there are any unsaved open workbooks when the Quit method is invoked, Excel will
display the usual dialog box asking the user whether he or she wants to save the changes. We can
prevent this either by explicitly saving all workbooks (using the Save method) before invoking the
Quit method or by setting the DisplayAlerts property to False . However, in the latter case, any
unsaved data will be lost without warning!
It is also important to note that Excel checks the Saved property of a workbook in order to
determine whether to prompt for saving. Thus, if we set the Saved property to True but do not
save the workbook, Excel will quit without prompting to save the workbook (and without saving
the workbook).
16.1.9 Miscellaneous Members
Here are some additional members of the Application object. CellFormat, FindFormat and ReplaceFormat object
The CellFormat object works in conjunction with the FindFormat and ReplaceFormat properties
of the Application object to programmatically find and replace cell formatting.
Specifically, the new FindFormat and ReplaceFormat properties of the Application object each
return a unique CellFormat object. We can set the formatting properties of either of these
CellFormat objects and then use the Replace method of the Range object to replace the formatting
in the CellFormat object returned by the FindFormat property, with the formatting in the
CellFormat object returned by the ReplaceFormat property.
For example, the following code replaces cells that have been formatted as bold with bold italic
formatting. Note that nowhere in the code is a CellFormat object explicitly declared.
Sub Example_CellFormat()
' Replace Bold with Bold Italic
With Application.FindFormat
.Font.Bold = True
End With
With Application.ReplaceFormat
.Font.Bold = True
.Font.Italic = True
End With
Cells.Replace SearchFormat:=True, ReplaceFormat:=True
End Sub
Search JabSto ::

Custom Search