将excel中的数据按表格形式保存到word中:(在“工具”菜单中选中"引用"项 )
选择: MicroSoft Word 11.0 Object Libarary
代码:
Public Sub ExportWord() Dim WordApp As Word.Application Set WordApp = CreateObject("Word.Application") WordApp.Visible = True With WordApp Set newDoc = .Documents.Add With .Selection For Each C In Worksheets("Sheet1").Range("A1:B10") .InsertAfter Text:=C.Value Count = Count + 1 If Count Mod 2 = 0 Then .InsertAfter Text:=vbCr Else .InsertAfter Text:=vbTab End If Next .Range.ConvertToTable Separator:=wdSeparateByTabs .Tables(1).AutoFormat Format:=wdTableFormatClassic1 End With End With Set WordApp = Nothing End Sub