, . , . → UserForm. , Windows.
VBA , 1. F1.
1
BackColor | . |
BorderStyle | , |
Caption | , . |
Font | . |
Height | . |
(Name) | , VBA. |
Width | . |
, . , : frmForm1.Caption = "". Windows . , , , .., . , , . , , , .. . , , . 2 .
2
Initialize | . |
Activate | . |
Deactivate | , . |
Click | . |
, .
Private Sub UserForm_Activate()
frmForm1.Caption = " "
End Sub
Private Sub UserForm_Click()
frmForm1.Width = frmForm1.Width / 2
frmForm1.Height = frmForm1.Height / 2
frmForm1.Caption = " !"
End Sub
. , . . , 3 4 .
3
Hide | UserForm, . |
Show | UserForm. |
4
|
|
Load | UserForm, . |
Unload | UserForm . |
, frmForms. Initialize frmForm1, frmForm2 . frmForm2, , frmForm1. frmForm1, frmForm2 .
' Initialize frmForm1.
Private Sub UserForm_Initialize()
Load frmForm2
frmForm2.Show
End Sub
' Click frmForm2
Private Sub UserForm_Click()
frmForm2.Hide
End Sub
' Click frmForm1
Private Sub UserForm_Click()
frmForm2.Show
End Sub
, → ( 2).
2 .
. , . ( ) , .
() ( ), .
. , - . 5 .
5
3 | ||
frm | frmMyForm | |
lbl | lblInfo | |
txt | txtInput | |
cmd | cmdExit | |
chk | chkSound | |
opt | optLevel | |
lsb | lsbTypes | |
fra | fraChoices | |
vcb | vcbSpeed | |
pic | picChema |
, , , .. 6. Caption & , Alt . Tab, Enter.
6
BackColor | . |
Caption | , . |
Enabled | False . |
Font | . |
ForeColor | . |
(Name) | , VBA. |
Picture | . |
PicturePosition | . |
Visible | False . |
Click. , , .
|
|
SetFocus, ( ). , : cmdMyButtum.SetFocus
. 7.
7
Enabled | False . |
Font | . |
ForeColor | . |
(Name) | , VBA. |
MaxLength | . |
PasswordChar | , . |
Text | . |
, :
txtResult.Text=" "
Change, . , cmdMyButtum. SetFocus Change .
, "" , . , ( ). 8.
8
Caption | , . |
Font | . |
ForeColor | . |
(Name) | , VBA. |
Picture | . |
PicturePosition | . |
. . . , . 9.
9
(Name) | , VBA. |
ListIndex | 1. |
Text | . |
Click DblClick ( ). .
AddItem, . AddItem UserForm _ Initialize (), . RemoveItem . Clear . , , , (List1 List2). . , .
Private Sub UserForm_Initialize ()
List1.AddItem ""
List1.AddItem ""
List1.AddItem ""
List1.AddItem ""
List1.AddItem ""
End Sub
Private Sub List1_DblClick ()
List2.AddItem List1.Text
|
|
List1.RemoveItem
List1.ListIndex
End Sub
Private Sub List2_dblClick ()
List1.AddItem List2.Text
List2.RemoveItem
List2.ListIndex
End Sub
. , , . 10.
10
Caption | , . |
(Name) | , VBA. |
Value | True , . |
Value True ( ), . Click , , . Click.
, . . , (. 10). Value ( , ).
Click, Value. , , (ChkBold ChkInalic) TxtExam (. 3). , . FontBold FontItalic .
3 .
Private Sub Chkbold_Click()
If ChkBold.Value = True Then TxtExam.FontBold = True Else TxtExam.FontBold = False
End If
End Sub
Private Sub ChkItalic_Click()
If ChkBold.Value = True Then TxtExam.FontItalic = True Else TxtExam.FontItalic = False
End If
End Sub
, , . , . Caption, , .
. (.BMP), (.ICO), (WMF), JPEG (.JPG) GIF (.GIF). 11.
11
Autosize | True . |
(Name) | , VBA. |
Picture | . |
.
Initialize Load Show. Run/Run Sub/UserForm . - . BackColor.
|
|
, Click. :
- Insert/UserForm(/UserForm);
- UserForm2 (. ):
UserForm2
Dim sRED, sGREEN, sBLUE '
' Initialize
' :
Private Sub UserForm_Initialize()
'
sRED = 100
sGREEN= 100
sBLUE= 200
UserForm2.BackColor= RGB(sRED, sGREEN, sBLUE)
End Sub
' Click
' . sRED, sGREEN, sBLUE :
Private Sub UserForm_Click()
Dim i
' :
sRED = sRED+ 20
sGREEN = sGREEN + 10
sBLUE= sBLUE - 20
i = RGB(SRED, SGREEN, SBLUE)
UserForm2.BackColor= i
UserForm2. Caption= ": " & Str(i)' :
End Sub
UserForm2 Click .
BackColor RGB, RGB- Long, UserForm2.BackColor. RGB: RGB(red, green, blue); : Red, Green, Blue ; : Variant (Integer); 0 255; , ).
4
.
MS Word.
1. :
1.1. .
1.2. , , MS Word.
2. :
2.1. .
2.2. IBM PC/XT.
2.3. MS Word.
2.4. Visual Basic for Application.
3. :
3.1. ( ).
3.2. , , . :
Q ;
U ;
t ;
S ;
l ;
× 2/.
3.3. , , . (. 1).
3.4. . , .
3.5. (. ). Locked TextBox () True, .
1 .
3.6. (. 2).
2 .
3.7. ().
3.8. . .
3.9. .
4. :
4.1. .
4.2. .
4.3. .
4.4. .
4.5. .
4.6. .
5. :
5.1. Word.
5.2. Word.Application?
5.3. , .
5.4. Document?
5.5. , ?
5.6. Range Selection.
5.7. ?
5.8. Word?
Word
Word.Application
VBA, , , Word, . Word. Word Application, Word. 180 . Application : , .
|
|
Word.Application
: - () ( VBA).
CommandBars, Assistant, FileSearch.
Word Documents Templates, , . .
AutoCorrect . . Browser , . Dialogs , Word. . , .
, : Languages, Dictionaries, SpellingSuggestions , , , , . , .
Options , .
Document
, Documents, . . Add, Open Documents. , , , . Item, . Save , Close, , .
Dialogs . wdDialogFileOpen Dialog.
,
. , . . , : , , , : , , .
Characters, Words, Statements, Paragraphs, Sections () , , , . . Characters, Words Statements Range. Range , . , , , Range, , . Range.
Document
Document , .
1 Document
Open | Documents , , |
New | |
Close |
, .
1) Subdocuments (Subdocument) . . 1020 , . . , , , , . AddFromRange SubDocuments , , Range.
2) Tables (Table), TablesOfAuthoritiesCategories (T.O.A.C), TablesOfAuthorities (TableOfAuthorities), TablesOfContents (TablesOfContent), TablesOfFigures (TablesOfFigure). Table . .
3) Shapes(Shape), InlineShapes(InlineShape) , . ActiveX OLE- . , : , .
4) Lists(List), ListParagraphs(ListParagraph), listTemplates (ListTemplate) , . . : -. ListTemplates , ListTemplate . , . Lists ( ), -. ListParagraphs . ListParagraphs, , , List Range. List . , . ListFormat.
5) Comments(Comment), Bookmarks(Bookmark), FootNotes (FootNote), EndNotes(EndNote), Fields(Field) , . , . .
a) comments comment . , , . range.
b) , , . bookmarks .
c) . : ( ) ( ). footnotes, endnotes.
6) Fields (Field) . , .
7) Story Ranges (Range) , (Story). . , Add. , . , wdStoryType. , wdMainTextStory. , , , . . Range. , , .
8) Variables (Variable) Variant. , , , . . , , , - .
Range Selection
Document Range, Range, Select, Selection. Range , Range; Select , Selection . Range Select, Range . Select Selection. , Selection Range, Range, .
() Range Selection.
Range : . ( ) Range: ActiveDocument.Range.Sections(1).Range.Paragraphs(l).Range.Sentences(1). Words(1).Characters(1)
Range Selection : , , , . , . , .
Range Selection. , Start End . , .
Move . . Move(Unit, Count) , , . Unit , a Count ( 1). Count . , . . , , 0, . Unit wdCharacter ( ), wdWord, wdSentence, wdParagraph, wdSection, wdStory, wdCell, wdColumn, wdRow wdTable.
, Range Selection. Range, . , ActiveDocument.Paragraphs(l).Range.Move , . Move , , , . MoveStart MoveEnd , .
Delete . , Range Selection. Delete(Unit,Count), . Unit , : wdWord wdCharacter. Count . , Count.
Insert Range Selection . InsertBefore(Text) InsertAfter(Text). text string , , range selection. , .
Text , Insert(Text). InsertBefore InsertAfter , , . , . , InsertSymbol InsertParagraph, .
, , ( ) . cut, , . , . , . CopyFormat, selection. , . CopyFormat selection.
Paste () , Range Selection. , , . Paste Range Selection, . PasteFormat , , Selection.