Retrieving the COM class factory for component error while generating word document

前端 未结 8 1058
时光取名叫无心
时光取名叫无心 2021-01-02 12:45

I am trying to edit a word document from VB.NET using for the most part this code:

How to automate Word from Visual Basic .NET to create a new document

相关标签:
8条回答
  • 2021-01-02 12:46

    It sounds like you may have a permission issue in DCOM. Try editing the Word permissions in DCOM config.

    0 讨论(0)
  • 2021-01-02 12:54

    Go to Start -> Run
    type regedit -32 and press enter key.
    -- Registry Editor will get open.
    Go To registry HKEY_CLASSES_ROOT\Word.Application
    Select Word.Application and set full permission to below users:-
    Administrator, Administrators, Local Service, System, Service, Interactive and Users.

    0 讨论(0)
  • 2021-01-02 12:55

    It definitely sounds like a permissions problem. Are you running your code in a windows service? The service normally runs as Local System, which may not have permission to access the Word object model. Additionally, if word is already running using the credentials of some other user then your program may not be able to access it via COM using different credentials. The office applications tend to be single instance which seems to exacerbate this problem.

    0 讨论(0)
  • 2021-01-02 12:57

    In my case, Word is running through a Windows Service under a service account.

    The problem was that the Desktop folder didn't exist in C:\Windows\System32\config\systemprofile (or in C:\Windows\SysWOW64\config\systemprofile).

    Adding it resolved the issue for me.

    0 讨论(0)
  • 2021-01-02 13:02

    I had the same issue on Windows 2008 R2. Ended up using this post: http://social.msdn.microsoft.com/Forums/en-US/netfx64bit/thread/65a355ce-49c1-47f1-8c12-d9cf5f23c53e

    and then changing the impersonation identity user in web.config to another user to solve it.

    I'm sure there is a combination of solutions.

    0 讨论(0)
  • 2021-01-02 13:04

    I was experiencing the same issue and the problem area I found was "security configuration for Microsoft Word in DCOM". On the following link you can find a step by step guide to know how to config components in DCOM, repeate these steps for WORD, and your problem will be solved.

    http://www.biocompsystems.com/_public/DCOMConfigurationStepbyStepForXP.doc

    Thanks, Sushil Jinder

    0 讨论(0)
提交回复
热议问题