Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people, just like you, are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
Solved

Clarify file types

Posted on 2009-03-30
1
613 Views
Last Modified: 2013-12-17
TEMPLATE_FILENAME points to a file that already exists and has been set up as a mail merge document, correct? What kind of file is FILE_NAME and what is contained in that file?
//This is the code previously posted
   //Open Microsoft Word
            Microsoft.Office.Interop.Word.ApplicationClass wordapp = new Microsoft.Office.Interop.Word.ApplicationClass();
            wordapp.Visible = false;
 
            object filename = TEMPLATE_FILENAME;
            object objTrue = true;
            object objFalse = false;
            object objMiss = Type.Missing;
            Microsoft.Office.Interop.Word.Document myMergeDocument;
 
            //Open the Template file
            myMergeDocument = wordapp.Documents.Open(ref filename, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss, ref objMiss);
            myMergeDocument.Select();
 
            //Open the data source
            object format = Microsoft.Office.Interop.Word.WdOpenFormat.wdOpenFormatText;
            myMergeDocument.MailMerge.OpenDataSource(FILE_NAME, ref format, ref objFalse, ref objMiss, ref objTrue, ref objFalse,ref objMiss,ref objMiss,ref objMiss,ref objMiss,ref objMiss,ref objMiss,ref objMiss,ref objMiss,ref objMiss,ref objMiss);
            
            //Perform the Mail Merge!!!
 
            if (DIRECT_PRINT)
                myMergeDocument.MailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToPrinter;
            else
                myMergeDocument.MailMerge.Destination = Microsoft.Office.Interop.Word.WdMailMergeDestination.wdSendToNewDocument;
 
            myMergeDocument.MailMerge.SuppressBlankLines = true;
            myMergeDocument.MailMerge.DataSource.FirstRecord = (int)Microsoft.Office.Interop.Word.WdMailMergeDefaultRecord.wdDefaultFirstRecord;
            myMergeDocument.MailMerge.DataSource.LastRecord = (int)Microsoft.Office.Interop.Word.WdMailMergeDefaultRecord.wdDefaultLastRecord;
            myMergeDocument.MailMerge.Execute(ref objFalse);
 
            
            
            //Close the template document.
            myMergeDocument.Close();
 
            //Print the derived document.
                       
            wordapp.Visible = true;
            wordapp.ShowMe();
            return;

Open in new window

0
Comment
Question by:NBHmember
1 Comment
 
LVL 3

Accepted Solution

by:
WeiXi earned 500 total points
ID: 24029055
> TEMPLATE_FILENAME points to a file that already exists and has been set up
> as a mail merge document, correct?

Yes, correct.

> What kind of file is FILE_NAME and what is contained in that file?

That file contains the data source for the mail merge. If, for example, you are creating standard circular letters, it would contain the names and addresses of the recipients.

The format of that file can vary, MS-Word supports quite a range. Popular examples include MS-Excel, MS-Access, or CSV. I guess XML should be supported as well, but I am not sure about it.

This is the file you open from MS-Word, when you click on the "open datasource" icon in the "mail merge" tool-bar.
0

Featured Post

Networking for the Cloud Era

Join Microsoft and Riverbed for a discussion and demonstration of enhancements to SteelConnect:
-One-click orchestration and cloud connectivity in Azure environments
-Tight integration of SD-WAN and WAN optimization capabilities
-Scalability and resiliency equal to a data center

Question has a verified solution.

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

Suggested Solutions

Title # Comments Views Activity
Find fonts in Word 2010 32 51
Need to get a Word Count from a Word file 19 39
how to double quote a string for an inline sql statement. 8 73
how to just get time from a date 6 32
Shortcuts in Word Just the other day I had a training for Microsoft and they wanted me to show how well the new Windows and Office behaved on a touch device, which by the way is great, but it was only then that I realized that using keyboard shortc…
It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
This video shows where to find templates, what they are used for, and how to create and save a custom template using Microsoft Word.
This is Part 3 in a 3-part series on Experts Exchange to discuss error handling in VBA code written for Excel. Part 1 of this series discussed basic error handling code using VBA. http://www.experts-exchange.com/videos/1478/Excel-Error-Handlin…

856 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