王哥哥,看看行不行!(0分)

  • 主题发起人 cyf_00002
  • 开始时间
C

cyf_00002

Unregistered / Unconfirmed
GUEST, unregistred user!

Private Sub Print_Word_Indeed(Y_Min As Integer, X_Min As Integer, Y_Max As Integer, X_Max As Integer)
Dim Word1 As Word.Application, i As Integer, j As Integer
Set Word1 = New Word.Application
If Word1.Documents.Count = 0 then
Word1.Documents.Add
End If
Word1.Visible = True
Word1.ActiveDocument.Tables.Add Range:=Word1.Selection.Range, NumRows:=X_Max - X_Min + 2, NumColumns:=Y_Max - Y_Min + 1, DefaultTableBehavior:=wdWord9TableBehavior, AutoFitBehavior:=wdAutoFitFixed
'生成表格
'写入表头
On Error GoTo Err2
For i = 1 To (Y_Max - Y_Min + 1)
If Word1.ActiveDocument.Tables.Count >= 1 then
With Word1.ActiveDocument.Tables(1).Cell(Row:=1, Column:=i).Range
.Delete
.InsertAfter Text:=DataGrid1(1).TextMatrix(0, Y_Min + i - 1)
End With
End If
Next
'写如表内容
For i = 1 To X_Max - X_Min + 1
For j = 1 To Y_Max - Y_Min + 1
If Word1.ActiveDocument.Tables.Count >= 1 then
With Word1.ActiveDocument.Tables(1).Cell(Row:=i + 1, Column:=j).Range
.Delete
.InsertAfter Text:=DataGrid1(1).TextMatrix(X_Min + i - 1, Y_Min + j - 1)
End With
End If
Next
Next
Word1.Visible = True
Me.MousePointer = 0

Exit Sub
Err2:
On Error Resume Next
' Word1.Quit
Me.MousePointer = 0

End Sub
 

Similar threads

I
回复
0
查看
570
import
I
I
回复
0
查看
781
import
I
I
回复
0
查看
807
import
I
I
回复
0
查看
498
import
I
I
回复
0
查看
600
import
I
顶部