none
Office automation code not working Windows 7 machine RRS feed

  • Question

  • I am trying to open a word document using office automation on Windows 7 machine. Using following Invoke functions to Open a word document.

    pDisp->GetIDsOfNames(IID_NULL,L"Open",1,LOCALE_USER_DEFAULT,&dispID);
      hr = pDisp->Invoke(dispID,IID_NULL,LOCALE_SYSTEM_DEFAULT,flags,&dp,pResult,0,0);

    where dp - display parameters

    pResult - document object

    This code works well on Windows Server 2003 and 2008 machine, however on Windows 7 machine getting "Empty" pResult object and hence following call is failing and I am unable to view the document.

     m_hr = RS_Invoke(pResult.pdispVal,L"PrintOut",DISPATCH_METHOD,NULL,0);

    Monday, February 3, 2014 6:25 AM

Answers

  • Hi Eugene,

    We found the solution from following post and it is working for us !!

    http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

    Solution

    32-bit systems:

    1) browse to the folder: C:\Windows\System32\config\systemprofile

    2) create a new folder and name it "Desktop".

    3) you're done.

     64-bit systems:

    1) Do what I described for 32-bit systems.

    2) browse to the folder: C:\Windows\SysWOW64\config\systemprofile

    3) create a new folder and name it "Desktop".

    4) you are done.



    Wednesday, February 5, 2014 5:56 AM

All replies

  • Hello Varsha,

    What Office application are you trying to automate? Could you please also specify their versions including the build number?

    Do you have different locale settings on machines with Windows Server and Windows 7?

    Monday, February 3, 2014 11:14 AM
  • Hi Eugene,

    I have a legacy product with a web based client that uses office automation to open office documents and subsequently pass it on to a third party PDF converter. The product installation is supported on Win 2K3/2K8/2K12. Any appropriate Office suite (Office 2003/2007/2010/2012) can be installed on these platforms which are then used as office automation.

    In certain scenarios, I get Office conversion error (intermittently reproducible on few environments). One such Office installation with which I am able to reproduce currently is "Office 2010 Professional Plus" and the build no. that I see in the Add/Remove Programs is "14.0.6029.1000". Is this what you are looking for when you ask details about the version including the build no.? 

    There is no specific difference in locale settings on machines, both are EN-US OS.

    Thank you for your prompt response as usual :) Let me know if you want any other details.

    - Varsha


    Monday, February 3, 2014 12:03 PM
  • Hi Varsha,

    First of all, I'd recommend installing the latest updates and service packs. It looks like you have got only SP1 installed for Office 2010. However, the SP2 is available for download and install. Please read more about the update in the Description of Office 2010 Service Pack 2 article.

    Please take a look at the Considerations for server-side Automation of Office article which states the following:

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    Office 2007 supports new Open XML file   formats that let developers create, edit, read, and transform file content on   the server side. These file formats use the System.IO.Package.IO namespace in the Microsoft .NET 3.x Framework to edit Office files without using the Office client applications themselves. This is the recommended and supported method for handling changes to Office files from a service.

    If your business requires the server-side creation of the Office 97, Office 2000, Office XP, and Office 2003 binary file formats, third-party vendors offer components that can help you. Microsoft does not provide any such components, so you will need to either build a solution yourself or purchase one from a third-party vendor. Many different third-party products are available.

    Monday, February 3, 2014 12:18 PM
  • Hi Eugene,

    As per your recommendation installed office SP2, however getting the same office conversion errors. As described in previous post, my application is a web client application and all automation code is on server and it is written in C/C++ and hence cannot use .NET. 

    As this is legacy application and works well for earlier versions. we cannot use third  party vendor.

    - Varsha

    Tuesday, February 4, 2014 8:38 AM
  • Varsha,

    It doesn't matter whether you are trying to automate Office applications from unmanaged or managed application.

    Please refer to the Considerations for server-side Automation of Office article for more information.

    Microsoft does not currently recommend, and does not support, Automation of Microsoft Office applications from any unattended, non-interactive client application or component (including ASP, ASP.NET, DCOM, and NT Services), because Office may exhibit unstable behavior and/or deadlock when Office is run in this environment.

    Tuesday, February 4, 2014 10:31 AM
  • Hi Eugene,

    We found the solution from following post and it is working for us !!

    http://social.msdn.microsoft.com/Forums/en/innovateonoffice/thread/b81a3c4e-62db-488b-af06-44421818ef91

    Solution

    32-bit systems:

    1) browse to the folder: C:\Windows\System32\config\systemprofile

    2) create a new folder and name it "Desktop".

    3) you're done.

     64-bit systems:

    1) Do what I described for 32-bit systems.

    2) browse to the folder: C:\Windows\SysWOW64\config\systemprofile

    3) create a new folder and name it "Desktop".

    4) you are done.



    Wednesday, February 5, 2014 5:56 AM