Sub excel写入word()
On Error Resume Next
MsgBox "请耐心等待,导出要花几分钟时间!请按确定才开始进行导出!", vbInformation, "注意"
Dim i1 As Integer, str1 As String, str2 As String, arr1()
i1 = Range("C65536").End(xlUp).Row
arr1 = Range("c1:m" & i1)
str1 = ThisWorkbook.Path
str2 = Worksheets("基础数据").Range("A2").Value
Set wd = CreateObject("word.application")
Set wddocument = wd.Documents.Add()
wd.Visible = False
wddocument.SaveAs FileName:=(str1 & "\" & str2 & ".doc")
'-----------------------标题字体格式及居中----------------------
wd.Selection.TypeText (" ")
wd.activedocument.Paragraphs(1).Range.Font.Size = 22
wd.Selection.Font.Name = "黑体"
'wd.Selection.ParagraphFormat.Alignment = wdAlignParagraphCenter
For i1 = 1 To UBound(arr1)
wd.Selection.TypeText Text:=Join(Application.Index(arr1, i1), "")
wd.Selection.TypeParagraph
'-----------------------里面段落字体格式及居中----------------------
wd.Selection.Font.Name = "仿宋"
wd.Selection.Font.Size = 16
'----------------------------------------------------------------------------------------------
If i1 = 7 Then
ActiveSheet.ChartObjects("图表 1").Activate
ActiveChart.ChartArea.Copy
' ActiveWindow.Visible = False
' Windows("天天向上.xls").Activate
' Range("G3").Select
'wddocument.Application.Selection.PasteAndFormat (wdChartPicture) 'OFFICE2000以下版本不支持
wddocument.Application.Selection.Paste
i1 = 25
End If
'-----------------------------------------------------------------------------------------------
If i1 = 31 Then
ActiveSheet.ChartObjects("图表 2").Activate
ActiveChart.ChartArea.Copy
' ActiveWindow.Visible = False
'Windows("天天向上.xls").Activate
'Range("G3").Select
' wddocument.Application.Selection.PasteAndFormat (wdChartPicture)
wddocument.Application.Selection.Paste
i1 = 47
End If
'------------------------------------------------------------------------------------------
If i1 = 53 Then
ActiveSheet.ChartObjects("图表 3").Activate
ActiveChart.ChartArea.Copy
'ActiveWindow.Visible = False
Windows("天天向上.xls").Activate
Range("G3").Select
'wddocument.Application.Selection.PasteAndFormat (wdChartPicture)
wddocument.Application.Selection.Paste
i1 = 67
End If
'-----------------------------------------------------------------------------------------
Next
wd.activedocument.Save
wd.activedocument.Close
wd.Quit
Set wd = Nothing
MsgBox "导出WORD完毕!", vbInformation, "提示"
End Sub
http://zhidao.baidu.com/question/118466847.html参考资料:http://hi.baidu.com/mizuda/blog/item/826c1d2b74420427d42af1d8.html