CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 12 of 12
  1. #1
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Question MS Office automation pls help

    On my dev machine I have a full office 2013 along with my vs2010.

    On my customer's machine, we need to run office automation with excel. My customer bought excel (but not a full office), and office automation doesn't work (there's no Excel Application listed in Component Services).

    How to fix that?

    I'm sure it is something in Excel's options where I need to add something or whatever. I hope somebody can help. On my dev machine, it just came with office...

  2. #2
    Join Date
    Jul 2001
    Location
    Sunny South Africa
    Posts
    11,283

    Re: MS Office automation pls help

    Taking a guess here, but does your client have the Office PIA ( Primary InterOp Assemblies ) installed?

    If not, that could be your answer.

    Have a look here :

    http://social.msdn.microsoft.com/For...5-fc4d2916659d

    http://msdn.microsoft.com/en-us/libr...vs.100%29.aspx

    I hope it helps.

  3. #3
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: MS Office automation pls help

    Thank you for your fast response.

    I installed the PIA for office 2010 (there wasn't one for 2013), but I still don't see a MS Excel Application in Component Services under DCOM Config.

    Is there something else I need to do?

  4. #4
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: MS Office automation pls help

    I found another site, but it only worked partially:
    http://blogs.technet.com/b/the_micro...n-snap-in.aspx

    The first part of it gave me a non-functioning Ms Excel Application in DCOM Config. The Local Path was empty.
    I noticed in my own registry that I had
    {00020812-0000-0000-C000-000000000046}
    Under HKEY_CLASS_ROOT\CLSID.
    This key contains the path to Excel. My customer's computer doesn't have that key. But before I just add it (and might end up in some deadlock when installing or removing things), I wonder if just adding that key is the right thing to do - I'd prefer some installation to do that for me so it is done right.

  5. #5
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MS Office automation pls help

    Did you try to run the steps listed under "Re-Register the Excel application"? (and remember to run the cmd window as an administrator?)

  6. #6
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: MS Office automation pls help

    I tried, but apparently it didn't work. Calling
    EXCEL.EXE –REGSERVER
    made Excel try to open a document called "REGSERVER". Yay for Excel... <sigh>

  7. #7
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MS Office automation pls help

    Quote Originally Posted by Lars_V_J View Post
    I tried, but apparently it didn't work. Calling
    EXCEL.EXE –REGSERVER
    made Excel try to open a document called "REGSERVER". Yay for Excel... <sigh>
    Sometimes, it's not "Yay for Excel", but "Yay for documentation".

    Look at the bigger picture, since Excel.exe is an exe automation server, it's going to need to register itself, right?

    So a quick search with bing for "how to register excel.exe in com" yielded...
    http://support.microsoft.com/kb/291288

    Bottom line, use /regserver instead of -regserver

    If you don't have a background in COM, I suggest working through a few simple COM examples so that you understand how these pieces work together. It's generally pretty rare to manually have to add COM related registry entries.

  8. #8
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: MS Office automation pls help

    Tried that too, as the command line for automation on my machine is excel.exe /automation

    Didn't help, though. I still got a blank Local Path.

    But I've seen before with COM and COM+ that things that are "half way installed" so to speak gets stuck and can't be either installed or removed. That's why I'm hesitant to just try to add the missing reg keys, as I fear it will do more harm than good.

  9. #9
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MS Office automation pls help

    Did you run the command line as an administrator? Did you get back any error? Did you try to /unregserver and then /regserver? You could try to add the registry key manually and then try the automation. It may just be that an Office install is necessary to do Office Automation.

    Lastly, what are you trying to do with the Excel automation? Are you trying only to manipulate an excel file without actually displaying it? If so, then check out using ExcelLibrary in this post: http://stackoverflow.com/questions/1...e-from-c-sharp

    It allows you to read/write xls or xlsx files without COM interop or an OLEDB connection. I've used it and it works well.

  10. #10
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: MS Office automation pls help

    Yep, I did run things as administrator. No errors were returned. I have tried to unregserver first.
    I might try to install a full office (I have one, and if it works my customer can exchange the excel-only license of his for a full-office license).
    It seems there's a gazillion reg keys for Excel - I am afraid that I might not get them all.

    I use things like charts, so I don't think ExcelLibrary will suffice. I looked at it earlier, but I didn't see anything about charts. It seems that they just open a spreadsheet as a DB table.

  11. #11
    Arjay's Avatar
    Arjay is offline Moderator / EX MS MVP Power Poster
    Join Date
    Aug 2004
    Posts
    13,490

    Re: MS Office automation pls help

    Quote Originally Posted by Lars_V_J View Post
    I use things like charts, so I don't think ExcelLibrary will suffice. I looked at it earlier, but I didn't see anything about charts. It seems that they just open a spreadsheet as a DB table.
    Yes. ExcelLibrary is for reading from/writing to xls or xlsx files.

    Do a test install on a clean machine. Set a restore point and then install stand-a-lone Excel. Check the automation entries. Then revert the restore point and install a full version of Office, again check the automation entries. It could be that a full version of Office is required.

  12. #12
    Join Date
    Jun 2001
    Location
    Denmark
    Posts
    453

    Re: MS Office automation pls help

    That is also what I fear. I called MS, and the supporters said that they didn't do much with automation, but they decided that they thought it *should* work. Then they sent me some links about add-ins in general etc, but not something useful. I asked them several times if I needed a full office, but they said again that it "should work". Should. :-/

    I intend to uninstall the excel and install the same office I have. If that works, we'll (the customer) just buy a full office instead. It's probably cheaper than continuing on something that "should work", although it irks me to have to get a full office when we're only using excel and when a stand-alone excel "should work".

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured