Add word document and keep formatting

ε祈祈猫儿з 提交于 2020-01-07 02:50:42

问题


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

回答1:


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



来源:https://stackoverflow.com/questions/32472020/add-word-document-and-keep-formatting

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!