我可以使用VSTO代替Open XML来操作altChunk功能吗? [英] Can I use VSTO instead of Open XML to manipulate altChunk features?

查看:110
本文介绍了我可以使用VSTO代替Open XML来操作altChunk功能吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想将一个Word文档(称为"hidden.docx")嵌入到另一个Word文档(称为"host.docx")中.当最终用户在Word中打开host.docx时,根本看不到隐藏文件.docx.文件hidden.docx只能携带在host.docx内部,属于非结构化货物数据.

I would like to embed one Word document (call it "hidden.docx") into another Word document (call it "host.docx"). The document hidden.docx would not be visible at all when host.docx is opened in Word by an end-user. Document hidden.docx would only be carried inside host.docx, sort of as unstructured cargo data.

我所做的所有研究都指向我使用Open XML SDK提供的称为altChunk的东西.我已经安装了Open XML SDK,并获得了示例示例: http://msdn.microsoft.com/en-us/library/gg490656%28v=office.14%29.aspx

All research I have done points me to the use of something called altChunk offered by the Open XML SDK. I have installed Open XML SDK and got a sample working: http://msdn.microsoft.com/en-us/library/gg490656%28v=office.14%29.aspx

我的问题:为了将altChunk插入到docx中,我真的需要Open XML SDK吗?使用VSTO不能做到这一点吗?如果可以,怎么办?

My question: In order to insert an altChunk into a docx, do I really need the Open XML SDK? Can this not be accomplished using VSTO? If so, how?

[PS:我的最终目标是,对于一对文档,其中一个文档是原始文本,而另一个文档是另一种语言的翻译版本,则能够将原始文档保存在翻译后的文档中,这样就不会失去它.对于任何一个文档对,总是存在两个文档由于其中一个的错位而分离的风险.]

[PS: My ultimate goal is, for a pair of documents where one document is the original text and the other is its translated version in another language, to be able to preserve the original document within the translated document, so as not to lose it. For any document pair, there's always the risk that the two documents become separated through misplacement of one of them.]

推荐答案

是,不是.

1.)那不是AltChunks所做的. AltChunks是一种将一个文档嵌入到另一个文档中的方法,这样它们就可以合并在一起.它们不是隐藏的.如果您创建其中带有AltChunk的docx程序包,然后打开Word,Word将立即将该AltChunk合并到文档中. (如果AltChunk是另一个Word文档,其中还包含子级AltChunk,则它们也将被递归合并到父级中.)基本上,这是一种将内容合并在一起的简便方法,而无需重新整合其所有样式,rID等.保存文档并对其进行检查后,AltChunk将消失,您将注意到Word再次将文档合并回到了单个文档中.

1.) That's not what AltChunks do. AltChunks are a way to embed one document into another document such that they get merged together. They are not hidden. If you create a docx package with an AltChunk in it, and then open up Word, Word will immediately merge that AltChunk into the document. (If that AltChunk is another Word document that also contains child AltChunks they will be recursively merged into the parent as well.) Basically, it's an easy way to merge content together without having to reconsolidate all their styles, rIDs, etc. -- if you save the document and examine it, the AltChunk will be gone, and you will notice that Word has merged the document back together into a single document again.

2.)Range.InsertXML(如果提供了有效的扁平包将在后台调用与AltChunk相同的合并功能(包括相同的错误等).两者的行为相同,您甚至可以使用包含嵌入式AltChunk的OpenXML SDK创建文档包,然后将其插入(我已经在Word 2007、2010和2013中做到了)–当然,如上所述, AltChunk永远不会持久化,它们会立即合并到文档中.

2.) Range.InsertXML, if provided a valid Flat Package for a full Word document will, under the hood, invoke that same merge functionality (down to having the same bugs, etc.) that you would get from an AltChunk. The two behave identical, and you can even create a document package with the OpenXML SDK that contains embedded AltChunks, and insert those (I've done this in Word 2007, 2010, and 2013) -- of course, as I mentioned above, the AltChunks are never persisted, they're immediately merged into the document.

如果要将隐藏数据保存在文档中,建议使用自定义XML(请参阅Document.CustomXMLParts).但是请记住,至少在Word 2010中,撤消不会将更改还原到CustomXML部件.

If you want to save hidden data in a document, I recommend using Custom XML (take a look at Document.CustomXMLParts). Keep in mind though, at least in Word 2010, Undo does not revert changes to CustomXML parts.

这篇关于我可以使用VSTO代替Open XML来操作altChunk功能吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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