Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.word.mailmerge.fields
Chris Chris is offline
external usenet poster
 
Posts: 237
Default C# MailMerge from Excel

Hi all,

I am trying to do a mailmerge from a web app in C#. I am trying to use an
excel file as a datasource. My code is not running properly. I would
appreciate a little help. This is my code:

Word.ApplicationClass oWordApp = new Word.ApplicationClass();
object missing = System.Reflection.Missing.Value;
object oTemplate = @"c:\test\test.doc";

// some object are not used
Object oFalse = false;
Object oTrue = true;
Object oName = Environment.CurrentDirectory + @"\template.dot";
Object oFileName = Environment.CurrentDirectory + @"\saved.doc";
Object oFileFormat = Word.WdSaveFormat.wdFormatDocument;
// end new

Word.MailMerge wrdMailMerge;
Word.Document oWordDoc = oWordApp.Documents.Add(ref oTemplate,ref
missing,ref missing, ref missing);

wrdMailMerge = oWordDoc.MailMerge;

try
{
",
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing,
ref missing, ref missing, ref missing);

wrdMailMerge.Destination = Word.WdMailMergeDestination.wdSendToNewDocument;
wrdMailMerge.Execute(ref oFalse);

// Unload objects from the memory
wrdMailMerge = null;
oWordDoc = null;
oWordApp = null;
}
catch(Exception e)
{
Response.Write(e.ToString());
}

Thank you,

Chris
 
Thread Tools
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
How do I print an Excel Autoshape on a Word doc using mailmerge? TG in AZ Mailmerge 2 February 25th 06 04:15 PM
mailmerge using Word/Excel 500.00 in Excel shows as 500 nt 500.00 Switchengine Mailmerge 1 January 29th 06 07:53 PM
Excel as mailmerge data source Mary Ann Mailmerge 2 December 6th 05 06:10 PM
excel hangs in mailmerge harrow Microsoft Word Help 2 October 21st 05 04:48 AM
Mailmerge from EXCEL, custom format problem TonyB Mailmerge 1 December 1st 04 04:41 PM


All times are GMT +1. The time now is 08:53 AM.

Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 Microsoft Office Word Forum - WordBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Word"