我给你简单地做了一个代码,请运行之,该代码将自动处理SHEETS(1)中的内容。 Option Explicit Sub Example() '请在EXCEL VBE\工具\引用中勾选对于Microsoft Word 11.0(视版本)Object Library 的引用 Dim myWord As Word.Application, myDoc As Word.Document Dim xlRange As Range, i As Range, wdRange As Word.Range Dim endCell As String, myString As String, aText As String On Error Resume Next '忽略错误 Set myWord = GetObject(, "Word.Application") '返回对于Word程序的引用 If Err.Number <> 0 Then '如果没有打开的Word程序,则出错 Err.Clear '清除错误号 Set myWord = CreateObject("Word.Application") '创建一个对于Word程序的引用 End If With Sheets(1) endCell = .[A65536].End(xlUp).Address Set xlRange = .Range("A4:" & endCell) End With Set myDoc = myWord.Documents.Add '新建一个文档 With myDoc For Each i In xlRange If i.MergeCells = True Then aText = i.Value aText = VBA.Mid(aText, 2, Len(aText)) aText = VBA.LTrim(aText) aText = VBA.RTrim(aText) myString = myString & aText & Chr(13) .Content.InsertAfter myString .Paragraphs.Last.Previous(1).Range.ParagraphFormat.Alignment = wdAlignParagraphCenter .Paragraphs.Last.Previous(1).Range.Font.Bold = True myString = "" Else |