VBA, , :
, ;
, ;
, .
, Excel, , Name . ( Name , .) , Name . Add .
, .
VBA :
Object.identifier
Object . , .
Identifier ; VBA runtime- , .
Word-, :
1.
Sub ActDocum()
MsgBox " : " & ActiveDocument.Name
End Sub
(.) . - . , . - VBA, . - VBA.
. 1 ( VBA) Excel 2000/2002. .
1 Excel
Application | Excel |
Chart | |
Font | , , |
Name | |
Range | ( ) |
Window | Excel; , .. |
Workbook | |
Worksheet |
|
|
: . . , , , (read-only), , , , / (read-write).
, , Boolean, Object .
:
Object.property
Object VBA;
property , .
, . , - .
, :
Variable = Object.Property
Variable , ;
Object ;
Property , .
2.
Sub gg()
Dim AnyStr As String
AnyStr = ActiveSheet.Name
MsgBox AnyStr
End Sub
, Name Excel ActiveSheet, AnyStr.
- . ( ActiveSheet.Name , Excel):
MsgBox ActiveSheet.Name
AnyStr = " : " & ActiveSheet.Name
MsgBox LCase(ActiveSheet.Name)
VBA , . MsgBox FullName Excel; FullName , :
MsgBox ThisWorkbook.FullName
ThisWorkbook , . ThisWorkbook Sales.xls My Documents, , , "C:\My Documents \SALES.XLS".
() , , :
Object.Property = Expression
Object ;
Property , ;
Expression VBA, , .
, InstSheet, Name :
|
|
Sub rename()
ActiveSheet.Name = " "
End Sub
, , StatusBar Application( Application host- VBA, Excel) :
Sub rename()
Application.StatusBar = " "
Application.StatusBar = False
End Sub
Application.StatusBar , , (, ). , , .
Excel. Application.StatusBar False, Excel .
. 2 Excel Visual Basic for Application. , , , .
2.
/ | ||
ActiveCell | Object: | Application, Window |
ActiveChart | Object: | Application, Window, Workbook |
ActiveSheet | Object: | Application, Window, Workbook |
Address | Range | |
Cells | Range | Application, Range, Worksheet |
Charts | Application, Workbook | |
Count | Integer: | |
Fofmula | String: | |
Index | Integer: | Worksheet |
Name | String: | Application, Workbook |
Path | String: , | Addln, Application, Workbook |
Saved | Boolean: | Workbook |
Selection | Object: | Application, Window |
Sheets | Application, Workbook | |
StatusBar | String: | Application |
ThisWorkBook | Object: , | Application |
Type | Integer: , | Window, Worksheet, Chart |
Visible | Boolean: | Application, Worksheet, Range |
Value | (): , | Range |
Workbooks | Application | |
Worksheets | Application, Workbook |
3. ,
Sub TestObjectOl()
'
MsgBox ActiveSheet.Name
' :
MsgBox ActiveCell.Address
'
MsgBox ActiveCell.Formula
'
MsgBox ThisWorkbook.Path
'
MsgBox ThisWorkbook.FullName
'
ThisWorkbook.Close
End Sub