将文本从Excel中的范围复制到Word文档中

你怎么:

1)从Excel文档中的范围复制文本。
2)打开一个Word文档。
3)将文本插入到word文档的特定部分。

问候

科乔

编辑:这是方法

Dim wrdApp As Word.Application Dim wrdDoc As Word.Document Dim j As Integer Set wrdApp = CreateObject("Word.Application") wrdApp.Visible = True Set wrdDoc = wrdApp.Documents.Open("C:\Files\DailyStrategy.doc") With wrdDoc If wrdDoc.Bookmarks.Exists("MarketCommentry") Then wrdDoc.Bookmarks("MarketCommentry").Range.Text = shortString wrdDoc.SaveAs "c:\temp\test.doc" End If ' close the document Set wrdDoc = Nothing Set wrdApp = Nothing End With 

以下是一些可能有所帮助的文章:

在Excel中使用VBA控制Word中的Word

使用Excel VBA创buildWord文档

从Excel数据范围创build格式化的Word表格

以下是我为replaceWord中的书签文本而写的一些代码

 Sub FillBookmark(ByRef wdDoc As Object, _ ByVal vValue As Variant, _ ByVal sBmName As String, _ Optional sFormat As String) Dim wdRng As Object 'store the bookmarks range Set wdRng = wdDoc.Bookmarks(sBmName).Range 'if the optional format wasn't supplied If Len(sFormat) = 0 Then 'replace the bookmark text wdRng.Text = vValue Else 'replace the bookmark text with formatted text wdRng.Text = Format(vValue, sFormat) End If 're-add the bookmark because the above destroyed it wdRng.Bookmarks.Add sBmName, wdRng End Sub 

更多细节在这里

http://www.dailydoseofexcel.com/archives/2004/08/13/automating-word/