473,769 Members | 2,345 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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.Offic e.Interop.Word;
----
Word.Applicatio n WordApp = new
Microsoft.Offic e.Interop.Word. Application();
object missing = System.Reflecti on.Missing.Valu e;
object falseValue = false;
object trueValue = true;

private void WordProcess(str ing openDoc, string openXls, string saveDoc)
{
object fileName = openDoc;
Word.Document doc = WordApp.Documen ts.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.O penDataSource(l inkTo.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.E xecute(ref missing);
}
catch (Exception ex){}
finally
{
try
{
//doc.Save();//save word
CloseApp();//close word app
}
catch (Exception ex) {}
}
}

private void CloseApp()
{
WordApp.Documen ts.Close(ref trueValue, ref missing, ref missing);
WordApp.Quit(re f trueValue, ref missing, ref missing);
System.Runtime. InteropServices .Marshal.Releas eComObject(Word App);
GC.Collect();
//this.KillExcelP rocess();
}

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

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

Similar topics

4
316
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
6104
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 alternatives, and they all introduced various other problems, leading me to discount them). The main issue with this solution is that when there are problems with the
4
5102
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 field working fine, but the user 'saves' the file from the Binary field to a binary disk file and can then open it. It would be better for them to be able to just open the file directly for viewing etc. I can 'trigger' a load for the file myself, but...
2
2720
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) to the larger project, which works fine in IE and Firefox so far, but my little test fails in IE, and I cannot figure out why. http://geekforhire.org/tests/window_open_onload.html It's supposed to open the window, change the background color,...
10
2080
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 names in a list (members). I open both input and output file in binary mode and do the transformation. However, I can't open the resulting file, Word just telling that there was an error. Does anybody what I am doing wrong? Oh, and is this...
5
1923
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 static void OpenDocument(string aFilename) { IntPtr result;
0
5092
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
1395
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 open the selected file. Say MS word to open a .doc file, MS power point to open .ppt file, etc. In asp.net, I use Response.OutputStream.Write to achieve this, it's pretty easy. is that a similar way in Windows application? Thanks in advance!
2
4616
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. When you try to open the file, a dialog box opens stating that the file cannot be opened. I need to log which files wont open properly, and I'm hoping there is a way to automate the process.
0
9589
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
10222
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
10050
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
9999
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
9866
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
8876
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7413
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5310
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
3967
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system

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.