我是VBA新手,想寻求一些帮助。
我在Excel中有一个范围B3:B40中的Word文档列表。我想复制列表中的文档并粘贴到新文档中,而不更改页面格式。
我已经试过下面的代码,它给予我“运行时错误13”。有人能帮助这个情况吗?提前感谢任何帮助。
Application.ScreenUpdating=false
set objword = createobject("Word.Application")
set objdoc = objword.Documents.Add
objword.visible = true
set objselection = objword.Selection
Folderpath = "C:\desktop" 'where I save the word document that would be combined
set objtempword = createobject("Word.Application")
set tempdoc = objword.documents.open (Folderpath & "\" & Sheet1.Range ("B3:B40")
set objtempselection = objtempword.selection
tempdoc.range.select
tempdoc.range.copy
objselection.typeparagraph
objselection.paste
tempdoc.close
1条答案
按热度按时间cdmah0mi1#
我想这可能对你有用。缺少的是为每个文件(范围中的单元格)工作的周期。