Solved

Error Activating Word Application

Posted on 2010-08-31
2
1,044 Views
Last Modified: 2012-06-27
I have some code that will run on a server and will generate a word file, to be downloaded to the user.  Since it is running on a server, there is no good reason to have the Word application itself visible.  The trouble is that I cannot activate Word when I set visible to false.

The code below works fine.

When I comment out the line that says 'mswApp.Vislble = true", I get a COMError that it cannot activate the application.

Any idea why?  Why would it let me set the application to invisible if I cannot activate it once I do?

Thanks.



mswApp = new Microsoft.Office.Interop.Word.Application();
mswApp.Visible = false;
//
// Comment out the next line for production
//
mswApp.Visible = true;
mswApp.Activate();

Open in new window

0
Comment
Question by:TimAttaway
2 Comments
 
LVL 44

Accepted Solution

by:
AndyAinscow earned 500 total points
ID: 33569728
>>Any idea why?

Well activate gives it the focus - oops, it's hidden !!
0
 

Author Comment

by:TimAttaway
ID: 33570775
Ah!  I thought you had to activate the application before you could generate a document but in fact you don't.  Thanks.
0

Featured Post

Free Tool: Postgres Monitoring System

A PHP and Perl based system to collect and display usage statistics from PostgreSQL databases.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

Title # Comments Views Activity
How come this regular expression allows "e"? 14 45
defining NULL or 0 10 44
Deploying packaged application using SCCM steps ? 4 39
C# Linq Select From List 3 14
Exception Handling is in the core of any application that is able to dignify its name. In this article, I'll guide you through the process of writing a DRY (Don't Repeat Yourself) Exception Handling mechanism, using Aspect Oriented Programming.
Using Word 2013, I was experiencing some incredible lag when typing.  Here's what worked for me....
This video walks the viewer through the process of creating envelopes and labels, with multiple names and addresses. Navigate to the “Start Mail Merge” button in the Mailings tab: Follow the step-by-step process until asked to find the address doc…
This Micro Tutorial well show you how to find and replace special characters in Microsoft Word. This is similar to carriage returns to convert columns of values from Microsoft Excel into comma separated lists.

861 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