在Office2016中创建的模板在使用Microsoft Office 14.0库的代码中不起作用 [英] Templates created in Office2016 does not work in code, using Microsoft Office 14.0 library

查看:76
本文介绍了在Office2016中创建的模板在使用Microsoft Office 14.0库的代码中不起作用的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好。

我目前正在管理SharePoint 2010解决方案。我们正在将其升级到2016年,但这需要一段时间..用户已升级到Office 2016,我们在SharePoint 2010中使用的新文档模板中的某些功能是
not可以与我们的代码一起使用。

I'm currently managing an SharePoint 2010 solution. We're in a process to upgrade it to 2016, but it's going to take a while.. The users have been upgraded to Office 2016 and some functions in the new document templates we're using in SharePoint 2010 is not possible to use with our code.

代码从模板库复制模板(dotx,在2016年创建)并在另一个文档库中创建.docx,然后打开并且用户应该能够编辑文档。当我们更新模板时,它停止工作,文件是
"腐败"。但是当它打开模板并在我的代码之外保存为docx时它可以正常工作。

The code copies the template (dotx, created in 2016) from a template library and creates a .docx in another document library, then it opens and the user should be able to edit the document. When we updated the template it stopped working and the file is "corrupt". But it works fine when just opening the template and save as docx outside my code.

这是我处理复制/保存的代码:

This is my code to handle the copy/save:

SPFile documentTemplateStream =
 rootWeb.GetFile(string.Format("{0}/{1}", spListTemplates.RootFolder.Url,
          pDocumentTemplateName));

var bytes = documentTemplateStream.OpenBinaryStream();
SPList spDestinationList = GetList(pWeb, "MyCustomLibrary");
SPFolder spDestinationFolder = spDestinationList.EnsureFolderPathExists(pFolderName);
SPFile spNewfile = spDestinationFolder.Files.Add(string.Format("{0}/{1}", spDestinationFolder.Url, pFileName), bytes, true);






这不起作用,我首先想到的是我需要更新Microsoft Office库。如果我使用在word 2010中创建的旧模板,则此代码可以正常运行。

This does not work, and my first thought is that I need to update the Microsoft Office library. Becuase if I use the old template created in word 2010, this code works.

但是,这在SharePoint 2010服务器上是否可行?我是否冒着其他功能停止工作的风险,因为已经删除/更改了新库中的名称,或者我可以保留14.0库并仅使用16.0库吗?

But is that even possible on a SharePoint 2010 server? And am I risking other functions to stop working because the've been removed/name change in the newer library, or can I keep the 14.0 library and use the 16.0 library just for this?

我目前正在运行Microsoft Office 14.0库。 

I'm running version Microsoft Office 14.0 Library at the moment. 

推荐答案

迁移到Office 2016时,需要使用Microsoft Word 16.0对象库:

As migrated to Office 2016, it is necessary to use Microsoft Word 16.0 Object Library instead:

为了确保代码中没有错误,异常,我建议在更换库版本后进行调试和测试以确保它适用于Office 2016文件。

And for making sure, there is no error, exception in the code, I suggest to debug and test after replacing the library version to make sure it will work for Office 2016 file.

谢谢

最好的问候


这篇关于在Office2016中创建的模板在使用Microsoft Office 14.0库的代码中不起作用的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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