473,395 Members | 1,677 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 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 2032

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: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...

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.