"VBA Programming" 11.Application objects

Source: Internet
Author: User

Application Object Common Properties
"ActiveCell Properties"
The ActiveCell property returns a Range object that represents the cell in the current window or in the specified window. This property is not valid if the window does not display a worksheet.
"Code Area"

Subactivates the cell () Worksheets ("Sheet1"). Activate'activates the current cell     withActiveCell. Value="Tina"         with . Font. Bold=True    'set to Bold. Italic =True  'set to italic. Size = -      'Set Font size        End  with    End  withEnd Sub

"Results show"

Note: The word is displayed in B2 because I've already hovered over the mouse before executing.

"ActiveWorkbook Properties"
ActiveWorkbook is a read-only property that returns a Workbook object that represents the workbook in the active window
No window or Information window or Clipboard window is open as the active window, nothing is returned
"Code Area"

Sub Test ActiveWorkbook Property ()     Dim  as Object    Set obj = ActiveWorkbook    CStr(obj. Application.value)End Sub

"Results show"

"Caption Properties"
Caption is a read-write property that sets or returns the name displayed on the title bar of Microsoft's main window, which returns a string type. If the title is not set for Microsoft's main window, or if its value is set to empty, this property returns a
"Microsoft excle" as the default title
"Code Area"

Sub Change title ()     " oliver--excle " End Sub

"Results show"

The Range Property
The Range property returns a Range object that represents a cell or range of cells
Range Instance Address: http://www.cnblogs.com/OliverQin/p/6198441.html

"Selection Properties"
The Selection property represents the return of the selected object in the active window for the Application object
"Code Area"

Sub Test Selection Property ()    Worksheets ("Sheet1"). Activate    Range ("A1"). Select    ' clears the contents of the Sheet1 worksheet End Sub

"Results show"

Before execution

After execution

"Sheets Method"
The Sheets property is a read-only property that returns a Sheets collection whose type is a sheets object

SubTest Sheets Property ()DimWss asSheetsDimI as IntegerApplication.workbooks (1). ActivateSetWSS =Application.sheets Debug.Print"The current workbook name is as follows:"Debug.Print fori =1  toSheets.count Debug.Print Sheets (i). NameNextEnd Sub

"Results show"

"VBA Programming" 11.Application objects

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.