472,965 Members | 1,965 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,965 software developers and data experts.

How to open word file on background for process.

Ang
Hi,

I want to open a word file on background instead of showing the process
on client's screen. And then do mailmerge, after that allow user to
saveas. (user simply click the button and IE will ask user to open or
save as the file)

Below is the code but I donno how to do it on background. It's an aspx
program, thanks.

Ang

using Word = Microsoft.Office.Interop.Word;
----
Word.Application WordApp = new
Microsoft.Office.Interop.Word.Application();
object missing = System.Reflection.Missing.Value;
object falseValue = false;
object trueValue = true;

private void WordProcess(string openDoc, string openXls, string saveDoc)
{
object fileName = openDoc;
Word.Document doc = WordApp.Documents.Open(ref fileName, ref missing,
ref falseValue, ref missing, ref missing, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref trueValue, ref
missing, ref missing, ref missing, ref missing);
object linkTo = openXls;
object query = "SELECT * FROM `DataSource$`";

try
{
doc.MailMerge.OpenDataSource(linkTo.ToString(), ref missing, ref
missing, ref missing, ref trueValue, ref missing, ref missing, ref
missing, ref missing, ref missing, ref missing, ref missing, ref query,
ref missing, ref missing, ref missing);
doc.MailMerge.Execute(ref missing);
}
catch (Exception ex){}
finally
{
try
{
//doc.Save();//save word
CloseApp();//close word app
}
catch (Exception ex) {}
}
}

private void CloseApp()
{
WordApp.Documents.Close(ref trueValue, ref missing, ref missing);
WordApp.Quit(ref trueValue, ref missing, ref missing);
System.Runtime.InteropServices.Marshal.ReleaseComO bject(WordApp);
GC.Collect();
//this.KillExcelProcess();
}

*** Sent via Developersdex http://www.developersdex.com ***
Sep 11 '08 #1
0 1985

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Ruslan | last post by:
Hi, I open a word file using ShellExecute. But I have to know when the open file is closed. How could I know this? Is it possible or not?
0
by: David Akerman | last post by:
Hi, Background ======== I've written a Web App in C# which controls a pool of Word Applications for mailmerge purposes (not ideal using Word non-interactively I know, but I have explored...
4
by: Bishman | last post by:
Hi, Can someone suggest the best technique / method of opening a Word ( or any other ) Document from an SQL BLOB ? I have the process of saving and retrieveing the file from an SQL Binary...
2
by: cgrady | last post by:
I'm working on part of a larger project, and in trying to debug one aspect, I've got a small test file to work with. The code is practically identical (all important aspects match word for word)...
10
by: Antoine De Groote | last post by:
Hi there, I have a word document containing pictures and text. This documents holds several 'ABCDEF' strings which serve as a placeholder for names. Now I want to replace these occurences with...
5
by: Alan T | last post by:
I have created a mail merged document at run time. However, I cannot open the document everytime, sometime it did not get opened, sometimes it can. The document may be Word or text file. public...
0
by: mix01 | last post by:
Hi, I am trying to get some VBA code working, but am preplex as to why it does not work. I would really appreciate any level of help. Many thanks, Mix01 Version of the program
2
by: AY Xu | last post by:
I have a data grid view, list the files saved in SQL server. File type may different in different rows. I want to achieve: doule click one row in data grid view, a standard program be called to...
2
by: hharry | last post by:
Hello All, Does anyone know of a method to automatically detect if a file is corrupted ? Due to a failed backup process a number of files were corrupted. The files are mostly .xls, .doc, .pdf....
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
0
tracyyun
by: tracyyun | last post by:
Hello everyone, I have a question and would like some advice on network connectivity. I have one computer connected to my router via WiFi, but I have two other computers that I want to be able to...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...
2
by: GKJR | last post by:
Does anyone have a recommendation to build a standalone application to replace an Access database? I have my bookkeeping software I developed in Access that I would like to make available to other...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.