尝试使用InsertFile方法附加到Word文档 [英] Trying to use InsertFile Method to APPEND to Word Document

查看:104
本文介绍了尝试使用InsertFile方法附加到Word文档的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

活动文档称为最终文档"

Active Document is called "FinalDocument"

以下内容处于循环状态(即Report1,Report2等.)

The following is in a loop (ie. Report1, Report2, etc..)

  DoCmd.OpenReport ReportName, acPreview, , "Report1"

  DoCmd.OutputTo acOutputReport, ReportName, acFormatRTF, "WordDoc1"

  ActiveDocument.Content.InsertFile FileName:=WordDoc1, Range:="", _ 
  ConfirmConversions:=False, Link:=False, Attachment:=False

我已经成功地将文本从Report1传输到FinalDocument.

I am successfully getting text from Report1 to FinalDocument.

我的问题是在每遍循环中,InsertFile都在替换文本.

My problem is that on every pass throught loop, InsertFile is REPLACING text.

我想将Report1的文本附加到FinalDocument,从而一次建立一个FinalDocument.

I want to APPEND Text from Report1 to FinalDocument thereby building FinalDocument one pass at a time.

推荐答案

您应该使用Range对象,以便可以定位插入点.首先,将Range设置为整个文档,然后将其折叠"到一个点-就像按右箭头键使选择成为选择结束时的闪烁光标一样.

You should work with a Range object so that you can target the insertion point. First, set theRange to the entire document, then "collapse" it to a point - think of it like pressing the right-arrow key to make a selection a blinking cursor at the end of the selection.

例如:

Dim rng as Word.Range
Set rng = ActiveDocument.Content
rng.Collapse Word.WdCollapseDirection.wdCollapseEnd. 'Or use 0
rng.InsertFile FileName:=WordDoc1, Range:="", _ 
   ConfirmConversions:=False, Link:=False, Attachment:=False

这篇关于尝试使用InsertFile方法附加到Word文档的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆