10

  • Commentary
  • decrypted from 6600BB727CF0DC0B40151E753F65E12B source file
Citation preview

« »

П. С. Ивл ч в, Н. А. Ивл ч ва

10

2014

32.81 519.683 255 . C.

Авт ры:

– -

. .

;



. . » . .

,

-



.

. .,

-

,

,

255

,

Реце зе ты:



;

-

.

-

«

,

,

,

-

. .,

,

. .

. .– : , 2014. – 36 .

:

.

10. /

-

-

32.81 519.683

© ©

. .,

. ., 2014

, 2014

3

................................................................................................................... 4 1.

............................................................... 5 1. 2. 3. 4. 5. 6. 7.

.......................................................................... 5 Word ................................... 6 .................. 6 ..................................................................... 8 ................................... 9 . ..................... 9 ........... 11

2.

Visual Basic for Application .... 13 8. 9. 10. 11. 12.

.......... 15 ...................................... 17 ............................................................................ 18 Selection ) .......................................................... 19

( (

) ....................................... 20

3.

.................... 20 13.

....... 23

4.

................. 25 14. 15. 16. 17. 18. 19. 20. 21. 1. 2.

VBA ................................................................ 25 .............................................. 26 ............................................ 27 .................................................... 27 ............... 30 VBA .......................... 30 .......................................................................................... 31 ( ) 32 ,

,

UserForm . 34 20 ...... 36

4

-

,

.

«

»,

«

».

,

,

-

.

Visual Basic for Application, ,

2010. ,

.

Microsoft Office

,

.

(

. .)

, Courier.

, Arial.

,

,

5

1.

-

Microsoft Office

.

).

Visual Basic – ,

.

, MS Office Visual Basic for Application (VBA –

,

,

. -

:

– – – – –

,

(

;

,

);

-

; ; .

.

Normal.dotm ( Word).

,

.

,

Word,

.docm. 1.

1–

1.

.НШМб

MS Word 1.

,

.

MS

6

–2

;

,

–2

;



.

:

;

:

– 3 – Arial;

;



,

;

),

.НoМm.

2.

Word MS Word .

. 1. –

– 1 , – 12 – – .docm ( -



-

. , OK.

2.

.



Word. .

,



1 2 Word.

.

.

3

-

. 4 3.

. , AllCaps, Bold

. 3. .



. CenterPara,

,

-

VBA. ,



– ),

:

, ,

.

(

, ,

,

.

(

-

);

,

7

.

-

;

– ,

,

,

,

.

-

. –

1 2

. (

2)

-

.

2–

3 . .

-

4 ,

5 , 6 .

, . ,

.

,

-

, .

-

7 . 1. Ра .

:

. т.docm.

Word

, DelTxt.

-

8

,

.

, Shift+End. Delete.

2.

-

. 4. –

1 2 .

(

.

-

3)

,

.

3–

.

3

(

– –

, 1. . ,



, .(

,

),

-

.

.

, DelTxt. ,

-

9

, 3.) 2.

-

.

.

-

5. (

1 2), ,

. 2

,

.

,

. . 3 (

:

)



1. –

, .

.

-

, – Times New Roman,

. – 14 – 1,27 .

-

.

3. 1_Format_Text .

,

-

1_Format_Text.

Ctrl + T.

.(

Ctrl + T. ,

.)

,

.

4. .

6.

-

Visual Basic for Application (VBA). VBA, 1 2

– .

3

-

.

,

2.

-

. .

10

.

4 Application. 1.

Visual Basic for 1_Format_Text

VBA.

, End Sub.

Word Sub Office Word 4 VBA . – –

.



,

– ; –

;

,

,

.

,

– , И

-

:

,

,

И

. .

4–

, .

И

,

. ,

-

-

.

=

1ИFШЫЦКЭИTОбЭ

VBA

11

4.

Selection (

).

Selection, With … End With . , With … End With, Selection). Font Selection ParagraphFormat – . 2.

,

VBA

,

-

WholeStory, .

-

( , 1_Format_Text

4.

,

.

-

3. Selection.ParagraphFormat.LineSpacing = LinesToPoints(1.5) . VBA. 4.

.

Run Sub

,

.

,

. ,

. …

6.

1_Format_Text . 2_Format_Text. (wdAlignParagraphLeft), – (0). , 7.

К

-

,

,

(Д ). -

VBA. ,

, –

, -

. 1_Format_Text

5.

-

, .

,

-

12

1 2),

(

,

-

. Word

2 (

5).

-

3 . 4 5

. . OK.

6 7

,

.

5–

1.

3ИInsОrtИTablОs, – – – – ; – – –

6.

;

(Ctrl+Home); (Shift+End; Shift+ ; Shift+ …)

; (Ctrl+End);

;

13

– –

;

-

. 2. ,

3.

.

.

.

,

. 4.

.

.docm

6–

.

,

6,

.docm

2. Visual Basic for Application ,

.

,

. VBA. VBA.

– .

,

,

-

14

, – .

.

,

.

,

. И

Dim

-

As

,

,

,

1. 1–

VBA

,

Integer

2

Single

4

[-215; 215-1] [-2128;-2-149Ж [2-149; 2128-1] 231

2

[True, False]

1

String Boolean ,

,

,

И

-

= -

. VBA

(

(tables), ,

7

...). .

(paragraphs), VBA

String.

Word.

ActiveDocument.Tables.(1).Cell(2, 3).Range.Text

7–

-

VBA

15

8. 1.

8. 4_Edit_Tables, , , .

,

.

.

-

.

2.

4_Edit_Tables

.

VBA.

SuЛ 4ИEНТtИTКЛlОs() ActiveDocument.Tables.Add Range:=Selection.Range, NumRows:=1, NumColumns:=2 AМtТvОDoМumОnt.TКЛlОs(2).StвlО = " " End Sub

3.

,

. ,

,

. Selection ).

.

( VBA

-

16

8–

.НШМЦ

,

2. 4.

5.

6. 7. 8. 9.

, ActiveDocument.Tables(2).Rows(1).Select Selection, . .

.

. Selection.Paragraphs.Alignment = wdAlignParagraphCenter Selection.Font.Bold = True . ActiveDocument.Tables(2).Cell(1, 1).Range.Text = " " . . Selection.InsertRowsBelow 1 . (False), .

-

17

10.

.

.

.

.

-

9. .

InputBox(), И

=InputBoб(“

”,“

,

,

”) 9.

9–

IЧpuЭBШб()

1. ,

4_Edit_Tables

-

, . ActiveDocument.Tables(2).Cell(2, 1).Range.Text = InputBox(" ", " ") 2. 4_Edit_Tables , , , . 3. . . .

-

-

MsgBox(), MsgBox “ 4. MsgBox

”,

,“ ,

,

10. vbInformation.

4_Edit_Tables

” -

18

10 –

5.

,

MЬРBШб()

.

.

. 10. 4_Edit_Tables

,

. Ц

, .

. (

)

,

, «

»

Do

а Loop Until

ы

4_Edit_Tables

а

а

,

MsgBox()

. MsgBox(" MsgBox() 11. ,

?", vbYesNo, " vbYesNo

– MsgBox()

7.

") , 7.

,

6, -

19

11 –

MsgBox()

Dim yn As Integer, i As Integer ‘ yn = 6 ‘ , i=1 ‘ Do ‘ i=i+1 ‘ Selection.InsertRowsBelow 1 ‘ Selection.Font.Bold = False Selection.Paragraphs.Alignment = wdAlignParagraphLeft ActiveDocument.Tables(2).Cell(i, 1).Range.Text = InputBox(" " ") ‘ , ActiveDocument.Tables(2).Cell(i, 2).Range.Text = InputBox(" ", " ") yn = MsgBox(" ?", vbYesNo, " ") ‘

", -

Loop Until yn = 7

1. .

. .

. 8. 11.

,

.

Selection ) 4_Edit_Tables

(

,

, Selection.

1. 5, « ActiveDocument, 2.

,

4_Edit_Tables

.

,

. -

4_Edit_Tables . -

, .

-

4_0. »

,

Selection. .

20

12.

(

)

,

.

(

) ,

.

.

«

»

Do While а Loop

,

ы

а

InputBox(),

ancel,

1.

. 4_0

,

“”.

-

,

.

Dim i As Integer, x As String, y As String i=1 б = InputBoб(" ", " ") в = InputBoб(" Do While x "" And y "" ‘

а

Cancel.

, .

-

10,

x

,

y,

", "

,

-

,

")

-

Cancel



Loop

,

2. 10.

.

.

.

-

3. :   

Word

,

,

– Characters. – Words. – Sentences.

. Word :

21

– Paragraphs.

 1. -149

. .НoМm

,

+

.

(

:

):

– Times New Roman; – 14 ; – ; 2. ( ):  – Arial;  ;  – ;  – ;  – ; 3. ( 1):  – 10 ;  – ; 4. ( ,  – ;  – ;  – 12 ;  – (Selection.Paragraphs.KeepWithNext = True); 5. :  – 1,27 ;  – ; 6. ( ,  + 10 ; 7. ( ):  – ;  – 12 .   

). -

,

. 1.

+.

(

,

.НoМm.

-149

):

+

(

( ...):

-

ActiveDocu-

22

,

ment.Paragraphs), ), . .

" .

)

"

(

"

12).

"

,

"

-

". ( ,

"

-

".

(

.

,

-

-

.

.

= а _ а ы

For

(

.;

)

.

а

=

_

а

а ]

[Step

Next

. ( «

)

" (





", ). (« »

») «

,

» If

лов в

1

«

Then 1

Else в

2

2

End If

», « .

,

»

23

,

2. 2– Visual Basic =

< > And Or Not

= ≠ < >

-

. 13. 2.

,

. .

.

.

. – .

,

. -

. :

, .

.

3.

VBA

,

.

,

SuЛ

.НoМm.

-149

,

-

,

. .

0() ‘ Selection.WholeStory Selection.Font.Name = "Times New Roman" Selection.Font.Size = 14 Selection.Paragraphs.LineSpacing = LinesToPoints(1) Dim all_par As Integer, tek_par As Integer, i As Integer , tek_par



all_par

-

24 all_par = ActiveDocument.Paragraphs.Count ‘

-

tek_par = 1 ‘ Do While ActiveDocument.Paragraphs(tek_par).Range.Words(1) " ActiveDocument.Paragraphs(tek_par).Range.Words(1) " " ‘ ActiveDocument.Paragraphs(tek_par).Range. Select ‘

" And -

With Selection. Paragraphs ‘ .LineSpacing = LinesToPoints(1.5) .Alignment = wdAlignParagraphCenter End With With Selection.Font ‘ .Name = "Arial" .AllCaps = True .Bold = True End With tek_par = tek_par + 1 ‘ Loop ‘ Do While ActiveDocument.Paragraphs(tek_par).Range.Words(1) " ActiveDocument.Paragraphs(tek_par).Range.Words(1) " " ... tek_par = tek_par + 1 Loop ‘ For i = tek_par To all_par - 5 ActiveDocument.Paragraphs(i).Range.Select If ActiveDocument.Paragraphs(i).Range.Words(1) = " ‘

" Then

... Else

‘ ... If ActiveDocument.Paragraphs(i).Range.Characters(1) = "(" Then ‘ ... End If

End If Next i ‘ For i = all_par - 5 To all_par ...

" And

25 Next i End Sub

4. ,

VBA . . (UserForms).

-

Office VBA

,

UserForm

,

1.

.

,

,

.

,

,

-

,

. -

.

,

,

,

.

, –

, ,

,

,

. 14.

VBA .docm.

1.

VBA 12.

.

VBA

. View – Project Ex-

.

plorer. View – Code .

-

,

Alphabetic :

. .

,



View – Properties Window. . Categorized .

-

-

26

,

,



12 –

. (

-

.

VBA

.docm

,

,

14).

-

.

. 15. Insert – UserForm.

-

Project .

13,

.docm Name ( ).

1. .

,

, ,

.

. -

27

(

.

).

Caption

,

2.

. .

BackColor .

3.

.

13 –

16. 1. Project (

), Microsoft Word Objects ThisDocument – Document, Open ( )– . ,

Document_Open() UserForm1. 2. .

.

,

.docm, . 17.

1. Project (

),

Forms

.

-

.docm Private Sub Show -

UserForm1.Show. VBA.

28

UserForm1– Toolbox. 2.

14.

3.

Label

,

Caption,

В

.

-

. Font

.

10

В

4. . В

5.

?.

14 –

-

TextBox /

.

Text1.

,

Text

Value. 6. . 7. ,

Text

.

,

, ControlTipText, . .

.

. ComboBox

, -

29

. .

.

8.

,

-

, Style 2-fmStyleDropDownList.

,

. OptionButton.

-

. – Font.

Caption, -

9. .

Д , Value



.

True –

.

.

10

Com-

mandButton. . Click.

Caption. ,

.

10. 14. 11.

В

Enter,

, .

-

TabIndex

, . TextBox, ComboBox CommandButton 12. TabStop Tab. False, , 13.

-

– True. Default .

0, 1 .

2

-

,

. TabStop

False,

CommandButton

, CommandButton1

. True.

30

14. .

,

,

15. Document_Open(). Sub .

,

Height

,

Width

Private

,

.

, Sub Run ,

. .

Tab. VBA. 18.

-

AddItem

ComboBox. И .AddItem " Initialize, (

Show).

"

,

,

.

1. ize –

UserForm. Private Sub UserForm_Initialize(). ComboBox1

,

, . ComЛoBoб1.AННItОm "

Initial-



2. TextBox1.SetFocus TextBox1 . .

SetFocus 3. (

.

).

. 19. В .

, VBA.

,

VBA

. ,

Д ,

,

CommandButton1, Click.

.

-

31

Value. 1.

,

CommandButton1. Click.

-

,

-

.

Private Sub CommandButton1_Click() ActiveDocument.Tables(3).Cell(1, 1).Range.InsertAfter (ComboBox1.Value) ActiveDocument.Tables(3).Cell(1, 2).Range.Text = TextBox1.Value If OptionButton1.Value = True Then ActiveDocument.Tables(3).Cell(1, 2).Range.Font.Italic = True Else ActiveDocument.Tables(3).Cell(1, 2).Range.Font.Italic = False End If End Sub 2.

.docm

.

3.

.

.

.

.

CommandButton1_Click()

4. UserForm1.Hide,

.

. 20.

. 1. UserForm1.Show 2.

. ,

3.

.

VBA

– .



-

5

.docm, ,

4. 5.



.

UserForm1.Show. , .

.

,

,

5

VBA. 5

-

32

,

. 21.

. (

)

1.

(

).

,

-

.

SОХОМЭ,

RКЧРО, SОХОМЭТШЧ. RКЧРО; SОХОМЭТШЧ SОХОМЭ, SОХОМЭ SОХОМЭТШЧ

RКЧРО,

.

DШМuЦОЧЭ

, RКЧРО . ,

RКЧРО . RКЧРО:

: (

.

RКЧРО, , . RКЧРО SОХОМЭТШЧ.

RКЧРО – SОХОМЭ –

.

,

RКЧРО,

)

ActiveDocument.Range.Sections(1).Range.Paragraphs(l).Range.Sentences(1). Words(1).Characters(1)



RКЧРО

SОХОМЭТШЧ », « ,

», «

», «

.

SОХОМЭТШЧ. SЭКЫЭ

MШЯО ,

MШЯО(UЧТЭ, CШuЧЭ) , К CШuЧЭ – CШuЧЭ ,

EЧН

-

,

-

– .

, (

. . UЧТЭ

– .

.

,

. RКЧРО , .

».

1). .

.

,

-

33

, 0, . UЧТЭ аНCСКЫКМЭОЫ ( ), аНАШЫН, аНSОЧЭОЧМО, wdPaЫКРЫКЩС, аНSОМЭТШЧ, аНSЭШЫв, аНCОХХ, аНCШХuЦЧ, аНRШа аНTКЛХО. , Selection.Move Unit:=wdParagraph, Count:=2 . – , RКЧРО SОХОМЭТШЧ. RКЧРО, . , ,

MШЯО MШЯОSЭКЫЭ

ActiveDocument.Paragraphs(l).Range.Move

,

MШЯОEЧН

DОХОЭО(UЧТЭ,CШuЧЭ), UЧТЭ , аНАШЫН аНCСКЫКМЭОЫ. . IЧЬОЫЭ

IЧЬОЫЭBОПШЫО(TОбЭ) . TОбЭ , IЧЬОЫЭPКЫКРЫКЩС,

– ,

,

.

Delete

RКЧРО

,



.

,

. -

.

, ,

SОХОМЭТШЧ.

.

CШuЧЭ

. IЧЬОЫЭAПЭОЫ(TОбЭ). ,

RКЧРО

CШuЧЭ. SОХОМЭТШЧ ЭОбЭ

IЧЬОЫЭ(TОбЭ). , ,

ЬЭЫТЧР ЫКЧРО ,

IЧЬОЫЭBОПШЫО

.

: -

, ЬОХОМЭТШЧ. , IЧЬОЫЭAПЭОЫ . -

. IЧЬОЫЭSвЦЛШХ

34

1.

,

, UserForm

3–

UserForm

ActiveControl

,

.

BackColor Caption Controls

Long

,

Enabled

.

Boolean,

, False,

Font,

-

BackColor,

-

Font

ForeColor

,

,

(

)

4–

UserForm

Copy Windows ut Windows

,

Hide

,

-

, Paste Show

.

, 5–

Activate

-

Windows

UserForm

.

,

,

,

,

-

35

Click

,

DblClick

,

,

( )

,

( )

Deactivate

,

Initialize

,

-

Load

Resize Terminate

-

Show.

.

, ,

,

-

36

2.

20

Private Sub CommandButton1_Click() Dim n As Integer n = ActiveDocument.Tables(3).Cell(1, 1).Range.Paragraphs.Count Dim m As Integer m = ActiveDocument.Tables(3).Cell(1, 1).Range.Paragraphs(n).Range._ Characters.Count ActiveDocument.Tables(3).Cell(1, 1).Range.Paragraphs(1).Range.Select Selection.Move Unit:=wdParagraph, Count:=n - 1 Selection.MoveEnd Unit:=wdCharacter, Count:=m - 1 Selection.Text = ComboBox1.Value ‘ ActiveDocument.Tables(3).Cell(1, 1).Range.InsertAfter (ComboBox1.Value) ActiveDocument.Tables(3).Cell(1, 2).Range.Text = TextBox1.Value If OptionButton1.Value = True Then ActiveDocument.Tables(3).Cell(1, 2).Range.Font.Italic = True Else ActiveDocument.Tables(3).Cell(1, 2).Range.Font.Italic = False End If UserForm1.Hide End Sub

10

. .

50 60×90/16. .

,

. 1-

.

.

. . 2,3. , 18.