. - Microsoft Excel - VBA Word- . . . . -> -> .
Excel :

, - ( );
- , ;
- ;
- ( );
- .
, Excel.
, -

'====================================================================

Sub TestsGenerate()

' Word- Excel-

' ()

'

 

Dim test_count As Integer '

Dim quest_count As Integer '

Dim max_quest As Integer '

Dim list As String '

 

Worksheets("AI").Activate '

ActiveCell.SpecialCells(xlLastCell).Select

MaxString = ActiveCell.Row

'Worksheets("0").Cells(2, 1).Value = "x"

' Word

Dim WRD

Set WRD = CreateObject("Word.Application")

WRD.Visible = True

WRD.Documents.Open "C:\test.doc" ' Microsoft Word,

test_count = 24 ' ( )

quest_count = 5 ' ( )

max_quest = 120 ' ( ( ))

sea = 2

Randomize

For i = 0 To test_count Step 1 '

WRD.Selection.Font.Size = 14

WRD.Selection.Font.Bold = True

WRD.Selection.TypeText Text:=" #" + CStr(i)

WRD.Selection.Font.Bold = wdToggle

WRD.Selection.TypeParagraph

WRD.Selection.Font.Size = 12

'

Worksheets("0").Cells(sea, 1).Value = " " + CStr(i)

sea = sea + 1

For j = 1 To quest_count Step 1 '

num = Int(Rnd * max_quest) + 1

'MsgBox (num)

' ,

tmp = 0

For z = 1 To MaxString Step 1

If (Int(Cells(z, 2).Value) = num) Then

'MsgBox (Cells(z, 3).Value)

tmp = z

Exit For ' , z

End If

Next z

' Word,

If tmp = 0 Then

str1 = " : " + CStr(num)

MsgBox (str1) '

End If

If tmp <> 0 Then

WRD.Selection.Font.Bold = True

WRD.Selection.TypeText Text:=" #" + CStr(j)

WRD.Selection.Font.Bold = wdToggle

WRD.Selection.TypeParagraph

WRD.Selection.TypeText Text:=Trim(Cells(tmp, 3).Value)

WRD.Selection.TypeParagraph

'

For k = 1 To 4 Step 1 ' , 2, 3 4

If (Int(Cells(tmp + k, 2).Value) = 0) Then

WRD.Selection.TypeText Text:=Trim(Cells(tmp + k, 4).Value) + ". " + Trim(Cells(tmp + k, 5).Value)

WRD.Selection.TypeParagraph

'

If Len(Cells(tmp + k, 1).Value) <> 0 Then

Worksheets("0").Cells(sea, 2).Value = j

Worksheets("0").Cells(sea, 3).Value = num

Worksheets("0").Cells(sea, 4).Value = k

sea = sea + 1

End If

Else

Exit For

End If

Next k

WRD.Selection.TypeParagraph

'WRD.Selection.InsertBreak.WdBreakType.wdSectionBreakNextPage = True

WRD.Selection.InsertBreak (WdBreakType.wdLineBreak)

End If

Next j

sea = sea + 1

Next i

 

End Sub

'====================================================================

 



- .

, , ( ). :)
: apsheronka@mail.ru

VBA Excel Access
VBA RSS- Access
VBA Access
Visio Access
Power Point
()



@Mail.ru


 
 
VBA -2014
, E-mail: apsheronka@mail.ru
,


http://apsheronsk.bozo.ru - !


`