|
楼主 |
发表于 2009-8-30 04:19
|
显示全部楼层
[广告] Excel易用宝 - 提升Excel的操作效率 · Excel / WPS表格插件 ★ 免费下载 ★ ★ 使用帮助★
经过自己的努力终于把程序编出来了!!
这几天一直自己在查书,因WORD基础差,看得很辛苦,但自己想,一定能弄好它的。
Sub userbm()
Dim myarray()
Dim wdbkmk As String
Dim wdapp As Word.Application
Dim wdrang As Word.Range
Dim mydate As String
Dim i As Integer
'Dim myDoc As Word.Document
'Set myDoc = GetObject(ThisWorkbook.Path & "\j601.doc")
myarray = Array("工程名称", "单元名称", "仪表名称", "仪表型号", "仪表位号", "制造厂", "精确度", "出厂编号", "输入", _
"允许误差", "电气源", "输出", "迁移量", "分度号", "标准表名称")
Set wdapp = GetObject(, "Word.Application")
For i = 1 To 15
Set wdrng = wdapp.ActiveDocument.Bookmarks(myarray(i - 1)).Range
wdrng.Cut
mydate = ActiveWorkbook.Worksheets("Sheet1").Cells(i, 2)
wdrng.InsertBefore (mydate)
Next i
'Set wdrng = wdapp.ActiveDocument.Bookmarks(myarray(1)).Range
'wdrng.Cut
'mydate = ActiveWorkbook.Worksheets("Sheet1").Cells(2, 2)
'wdrng.InsertBefore (mydate)
Set wdapp = Nothing
End Sub
注意,word与excel文件都要打开,当然你可以修改下我的代码。 |
-
我要睡觉了
|