Creating Microsoft Word Object in Thread Fails on Deployed Workstation

Posted on 2011-10-06
Last Modified: 2012-06-27
I am running some office automation in a thread.  This works on my development machines, but fails when deployed.  If I run the same code outside of a thread, it works on all machines.  Does anyone have any ideas?  I became so frustrated that I created the most basic non-class driven automation to make sure I wasn't going crazy:

Attached are two files, same program but one calling via thread the other direct.


Question by:DuBoisCG
    LVL 26

    Expert Comment

    by:Anurag Thakur
    The first reason that comes to my mind in such a scenario when something works on development machine and not on deployment machine is the permissions of user under whose credentials the code/application is running under

    generally on dev machines we always have admin rights and when we deploy the user credentials the application is using is generally restricted
    LVL 2

    Author Comment

    It's a good thought, but the working test (same code, just not in a thread) runs as the local user.

    I actually got it working by adding the office.dll into the working directory, but want to leave this issue open to see if anyone can explain why this dll wasn't required for the working test.  If there are some important rules for threads that limit their ability to access resources, it would be nice to document it here (couldn't find much threaded function help).
    LVL 26

    Accepted Solution

    logged in users normally have higher permissions as they can create files etc on the PC when logged on.
    Office.Dll should have been there in your working directory (in the references you might have not selected copy local for the reference) thats why its missing when you deploy it
    It will work perfectly well on development because it knows from which path the reference has been added but on deployment machine the local copy is needed to make it run. Thats my observation and adding more i dont think that there are any specific rules for threads as a normal execution exe
    LVL 2

    Author Closing Comment

    We still don't know why the same code would run outside a thread on the same machine as the same user... but ultimately it needed the referenced dll in the working directory in order for the thread version to run.

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    If you haven’t already, I encourage you to read the first article ( in my series to gain a basic foundation of R and R Studio.  You will also find the …
    Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
    Viewers will learn how to properly install Eclipse with the necessary JDK, and will take a look at an introductory Java program. Download Eclipse installation zip file: Extract files from zip file: Download and install JDK 8: Open Eclipse and …
    The viewer will be introduced to the member functions push_back and pop_back of the vector class. The video will teach the difference between the two as well as how to use each one along with its functionality.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    17 Experts available now in Live!

    Get 1:1 Help Now