|
楼主 |
发表于 2015-12-21 14:51
|
显示全部楼层
这是我目前写出来的代码,目前已经是复制好指定区域,但是吧这个指定区域粘贴到word的相对应的区域
后面就卡壳了。。
Sub test000()
'复制指定的区域到目标区域
Dim xhs, xhs1, name As Variant
Dim wdname As Variant
Dim myrange As Range
'打开word
Set wo = CreateObject("Word.Application")
Filename2 = Application.GetOpenFilename(FileFilter:="Word文件(*.docx; *.doc;*.docm),*.docx;*.docm;*.doc", Title:="选择Word报告")
MsgBox Filename2
wo.Documents.Open Filename2
wo.Visible = True
wdname = CreateObject("Scripting.FileSystemObject").GetBaseName(Filename2) & ".docx"
MsgBox wdname
'打开EXCEL附注,并取得循环数
MsgBox ("请打开附注的Excel文件 ")
Filename = Application.GetOpenFilename(FileFilter:="Excel文件(*.xlsx; *.xls;*.xlsm),*.xlsx;*.xlsm;*.xls", Title:="选择Excel附注")
Workbooks.Open (Filename)
Worksheets("披露表").Select
xhs = Range("d1000").End(xlUp).Row
'MsgBox (xhs)
For xhs1 = 1 To xhs
Worksheets("披露表").Select
If Cells(xhs1 + 2, 4).Value = "披露" Then
name = Cells(xhs1 + 2, 5).Value
Set myrange = Range(name)
myrange.copy
Documents(wdname).Select '#####
MsgBox (ActiveDocument.FullName)
Else
End If
Next xhs1
End Sub |
|