以下是引用thumbring在2007-6-10 8:52:14的发言: 我已经将附件上传了,请版主指点。 以下代码供参考: '* +++++++++++++++++++++++++++++ '* Created By SHOUROU@ExcelHome 2007-6-10 12:00:20 '仅测试于System: Windows NT Word: 11.0 Language: 2052 '№ 0227^The Code CopyIn [Excel]^' '* ----------------------------- Option Explicit
Sub 按钮30_单击() Dim ws As Worksheet Dim i As Long Dim myRange As Range, C As Range Dim wd As New Word.Application, wdDoc As Word.Document Set ws = ThisWorkbook.Worksheets("案件表") Set myRange = ws.[A65536].End(xlUp) Set myRange = ws.Range(ws.[A2], myRange) For Each C In myRange Set wdDoc = wd.Documents.Add(ThisWorkbook.Path + "\行政管理局.doc", False) With wdDoc.Bookmarks .Item("负责人").Range.Text = C.Offset(, 1).Value .Item("性别").Range.Text = C.Offset(, 3).Value .Item("住址").Range.Text = C.Offset(, 4).Value .Item("电话").Range.Text = C.Offset(, 6).Value .Item("邮政编码").Range.Text = C.Offset(, 7).Value .Item("案发地").Range.Text = C.Offset(, 8).Value .Item("项目").Range.Text = C.Offset(, 9).Value .Item("查获日期").Range.Text = C.Offset(, 10).Value End With wdDoc.SaveAs ThisWorkbook.Path & "\abc\" & C.Row & ".doc" wdDoc.Close Next wd.Quit End Sub '----------------------
|