vba 使用excel宏在word中插入分页符

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/21120041/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-12 01:22:58  来源:igfitidea点击:

inserting page break in word using excel macro

excelexcel-vbavba

提问by user3194519

I am creating a macro that copies data from excel into word. I can't get the macro to insert a page break after I just copied the range of cells into word. I get the following error

我正在创建一个将数据从 excel 复制到 word 的宏。在我刚刚将单元格范围复制到 word 后,我无法让宏插入分页符。我收到以下错误

Object doesn't support this property or method.

对象不支持此属性或方法。

I am guessing this happens because the copied data in Word is still highlighted and I need to get a cursor at the bottom of the new copied date before I try to insert a page break.

我猜这是因为 Word 中复制的数据仍然突出显示,在尝试插入分页符之前,我需要在新复制日期的底部找到一个光标。

How do I do this?

我该怎么做呢?

This is a section of the code that is not working - actually the last line of the code but I thought I should show you right before as well:

这是一段不起作用的代码 - 实际上是代码的最后一行,但我想我也应该在此之前向您展示:

        Range("A1:F25").Select
         Selection.Copy

         appWD.Documents.Add

         appWD.Selection.PasteSpecial Link:=True, DataType:=wdPasteEnhancedMetafile
         DoEvents


        appWD.InsertBreak Type:=wdPageBreak