|
- Private Sub CommandButton1_Click()
- Dim ExcelApp As Object
- Dim wb As Object
- Set ExcelApp = CreateObject("EXCEL.application")
- Set wb = ExcelApp.Workbooks.Open(ActiveDocument.Path & "" & "样表.xls")
- arr = wb.Worksheets(1).Range("a1").currentregion.Value
- wb.Close False
- Set wb = Nothing
- With ActiveDocument.Tables(1)
- .Cell(2, 2).Range.Text = arr(2, 2)
- .Cell(2, 4).Range.Text = arr(2, 7)
- .Cell(3, 2).Range.Text = arr(3, 2)
- .Cell(3, 3).Next.Range.Text = arr(3, 4)
- .Cell(3, 3).Next.Next.Range.Text = arr(3, 6)
- For i = 6 To 44
- For j = 1 To 8
- If j = 4 Or j = 5 Then arr(i, j) = Format(arr(i, j), "0.0")
- .Cell(i, j).Range.Text = arr(i, j)
- Next
- Next
- With .Cell(44, 8).Range.Next.Next
- .Text = arr(45, 1)
- .Next.Text = arr(45, 4)
- End With
- For i = 46 To 47
- For j = 1 To 3
- If j = 3 Then arr(i, j) = Format(arr(i, j), "0.0%")
- .Cell(i, j).Range.Text = arr(i, j)
- Next
- Next
- .Cell(46, 3).Next.Range.Text = arr(46, 4)
- End With
- End Sub
复制代码 |
|