添加word文档并保持格式(Add word document and keep formatting)

其他开发 IT屋
百度翻译此文   有道翻译此文
问 题

I am attempting to add my CV to the end of a document. The following code does just that but the formatting of the CV is messed up once it is inserted into the new document. Can I insert the file and keep the original formatting of the CV (I dont want to copy and paste from an open document):

objword1.Selection.InsertFile Filename:=cv1Address, _
    ConfirmConversions:=False, Link:=False, Attachment:=False
解决方案

I'm afraid that you can't use the InsertFile-method but have to open the file and copy&paste with wdFormatOriginalFormatting

I have found this:

Set rtffile = wdApp.Documents.Open(Filename:="C:\temp\rtf_stapler_problem\concat\cars2.rtf", ConfirmConversions:=False, ReadOnly:=True)
wdApp.Selection.WholeStory
wdApp.Selection.Copy
wdApp.ActiveWindow.Close savechanges:=wdDoNotSaveChanges
destdoc.Activate
wdApp.Selection.PasteAndFormat (wdFormatOriginalFormatting)
wdApp.Selection.InsertBreak Type:=wdSectionBreakNextPage

here

本文地址:IT屋 » Add word document and keep formatting

问 题
我试图将我的简历添加到文档的末尾。下面的代码就是这样做的,但是一旦插入到新文档中,CV的格式就会混乱。我可以插入文件,并保持简历的原始格式(我不想从打开的文档复制和粘贴):

pre $ objword1.Selection.InsertFile文件名:= cv1Address,_
ConfirmConversions:= False,Link:= False,附件:= False

解决方案

恐怕你不能使用InsertFile方法,但必须打开文件并复制并粘贴 wdFormatOriginalFormatting



我发现这个:

 <$ c $ (设置rtffile = wdApp.Documents.Open(Filename:=“C:\temp\rtf_stapler_problem\concat\cars2.rtf”,ConfirmConversions:= False,ReadOnly:= True)
wdApp.Selection .WholeStory
wdApp.Selection.Copy
wdApp.ActiveWindow.Close savechanges:= wdDoNotSaveChanges
destdoc.Activate
wdApp.Selection.PasteAndFormat(wdFormatOriginalFormatting)
wdApp.Selection .InsertBreak类型:= wdSectionBreakNextPage


here


本文地址:IT屋 » 添加word文档并保持格式

官方微信
扫一扫关注IT屋
微信公众号搜索 “ IT屋 ” ,选择关注
与百万开发者在一起
}