kuguar » 11.05.2005 (Ср) 6:49
Private Sub ExpWord_Click()
Dim buf As String, Blank As String, i As Integer
Blank = "c:\Прайс_Бланк.doc"
Set objWord = New Word.Application
objWord.Visible = True
Set objDoc = objWord.Documents.Add(Blank)
objDoc.Activate
buf = Form1.Caption
objDoc.ActiveWindow.Selection.InsertParagraphAfter
objDoc.ActiveWindow.Selection.InsertAfter buf
objDoc.ActiveWindow.Selection.InsertParagraphAfter
objDoc.ActiveWindow.Selection.EndOf
objDoc.ActiveWindow.Selection.MoveDown wdLine, 3
objDoc.ActiveWindow.Selection.MoveLeft wdCharacter, 3
objWord.Visible = False
For i = 1 To MSFlexGrid.Rows - 1
With objDoc.ActiveWindow.Selection
.TypeText MSFlexGrid.TextMatrix(i, 1)
.MoveRight wdCharacter, 1
.TypeText MSFlexGrid.TextMatrix(i, 2)
.MoveRight wdCharacter, 1
.TypeText Trim(MSFlexGrid.TextMatrix(i, 3))
.MoveRight wdCharacter, 1
.TypeText MSFlexGrid.TextMatrix(i, 4)
.MoveRight wdCharacter, 1
.TypeText MSFlexGrid.TextMatrix(i, 5)
.MoveRight wdCharacter, 1
.TypeText Trim(MSFlexGrid.TextMatrix(i, 6))
.InsertRowsBelow (1)
End With
Next i
objWord.Visible = True
End Sub
Выглядит таким образом. (В Excel та же задача решается в течении 40 секунд)