|
本帖最后由 duquancai 于 2016-10-23 13:59 编辑
详见附件,打开Word文件,点击按钮》》》》》- Private Sub CommandButton1_Click()
- Dim cx As New ADO, sql$, p$, f$
- p = ThisDocument.Path & ""
- f = Dir(p & "*.xls*")
- sql = "select * from [" & p & f & "].[sheet1$]"
- arr = cx.筛选结果(p & f, sql)
- For i = 0 To UBound(arr, 2)
- For j = 0 To UBound(arr)
- If j = 0 Then
- s = arr(j, i)
- Else
- s = s & vbTab & arr(j, i)
- End If
- Next
- Selection.Text = s & vbCr
- Selection.Collapse wdCollapseEnd
- Next
- ActiveDocument.Content.ConvertToTable 1, UBound(arr, 2) + 1, UBound(arr) + 1
- ActiveDocument.Tables(1).Style = "网格型"
- End Sub
复制代码
|
评分
-
1
查看全部评分
-
|