简体   繁体   English

升级到 Office 365 后 Microsoft 与 Word 的互操作不起作用

[英]Microsoft interop to Word does not work after uprade to Office 365

I had Word templates in my database that are used for mail merge.我的数据库中有用于邮件合并的 Word 模板。

I used Office 2013 when I created this code with.Net 4.6:我使用 .Net 4.6 创建此代码时使用的是 Office 2013:

 Object theTemplateFile = theWordFileName =  Path.Combine(Path.GetTempPath(), _selectedCIPTemplate.Name + ".dotx");
            byte[] theTemplate = _selectedCIPTemplate.Template;
            using (FileStream stream = new FileStream(theTemplateFile.ToString(), FileMode.Create))
            {
                stream.Write(theTemplate, 0, theTemplate.Length);
            }

            Object oMissing = System.Reflection.Missing.Value;

            //Create an instance of Word
            Process.Start(theWordFileName);
            System.Threading.Thread.Sleep(2000);
           

            wrdApp = Marshal.GetActiveObject("Word.Application") as Microsoft.Office.Interop.Word.Application;
            wrdApp.Visible = false;

I recently upgraded to Office 365 64 bits en this code now breaks on te line:我最近升级到 Office 365 64 位 en 此代码现在在 te 行中断:

wrdApp = Marshal.GetActiveObject("Word.Application") as Microsoft.Office.Interop.Word.Application;

With the following error (sorry, Dutch): Het ophalen van de COM-classfactory voor het onderdeel met CLSID {000209FF-0000-0000-C000-000000000046} is mislukt vanwege de volgende fout: 80040154 Klasse is niet geregistreerd (Uitzondering van HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)).出现以下错误(抱歉,荷兰语):Het ophalen van de COM-classfactory voor het onderdeel met CLSID {000209FF-0000-0000-C000-000000000046} is mislukt vanwege de volgende fout: 80040154 Klasse is niet registreerd (Uitzondering van HRESULT: 0x80040154(REGDB_E_CLASSNOTREG))。

I tried reregister the class with regasm Microsoft.Office.Interop.Word.dll我尝试使用 regasm Microsoft.Office.Interop.Word.dll 重新注册 class

I compiled the project as Any CPU我将项目编译为 Any CPU

But it keeps failing.但它一直在失败。

Any tips how to solve this?任何提示如何解决这个问题?

Het ophalen van de COM-classfactory voor het onderdeel met CLSID {000209FF-0000-0000-C000-000000000046} is mislukt vanwege de volgende fout: 80040154 Klasse is niet geregistreerd (Uitzondering van HRESULT: 0x80040154 (REGDB_E_CLASSNOTREG)). Het ophalen van de COM-classfactory voor het onderdeel met CLSID {000209FF-0000-0000-C00046} is mislukt vanwege de volgende fout: 80040154 Klasse is niet registreerd (Uitzondering van HRESULT: 0x80040154).CLASSDBNOTREEG

This is a good indication that your windows registry keys were messed up.这很好地表明您的 windows 注册表项被弄乱了。 You need to remove old keys that were left after upgrading to Office 365.您需要删除升级到 Office 365 后留下的旧密钥。

If you try to install O365 on a clean machine you should get the code working correctly independently of the Office bitness whether it is x86 or x64 platform is used.如果您尝试在干净的机器上安装 O365,无论是 x86 还是使用 x64 平台,您都应该使代码独立于 Office 位数正常工作。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM