Click here to Skip to main content
15,892,059 members
Home / Discussions / C#
   

C#

 
GeneralAdding Progress Bars to ListView Pin
athomas42195-Dec-02 21:04
athomas42195-Dec-02 21:04 
GeneralRe: Adding Progress Bars to ListView Pin
Richard Deeming5-Dec-02 23:47
mveRichard Deeming5-Dec-02 23:47 
GeneralWhy Are Mnemonic (Keys) Not Showing On Windows Forms Pin
Gaul5-Dec-02 17:33
Gaul5-Dec-02 17:33 
GeneralRe: Why Are Mnemonic (Keys) Not Showing On Windows Forms Pin
Richard Deeming5-Dec-02 23:49
mveRichard Deeming5-Dec-02 23:49 
GeneralRe: Why Are Mnemonic (Keys) Not Showing On Windows Forms Pin
Gaul6-Dec-02 16:00
Gaul6-Dec-02 16:00 
QuestionIs there a PushbackInputStream for C# or a work around? Pin
Rodney S. Foley5-Dec-02 13:53
Rodney S. Foley5-Dec-02 13:53 
GeneralLoading Windows Form dynamically into splitter Pin
femthink5-Dec-02 12:24
femthink5-Dec-02 12:24 
GeneralMail Merging with Word & C# Pin
MrEyes5-Dec-02 6:02
MrEyes5-Dec-02 6:02 
Well my illustrious leader AKA the boss man, has set me the task of creating an C# application that will print mail merged word documents (merged with data from the C# application), so far I have come up with the following (there is a but, see after the code) :

<br />
private void PrintBookMarkedDoc()<br />
{<br />
 object oMissing = System.Reflection.Missing.Value;<br />
 object fileName = Environment.CurrentDirectory + @"\dev_template.dot";<br />
 object newTemplate = false;<br />
 object docType = 0;<br />
 object isVisible = true;<br />
<br />
 Word.Document ActiveDoc = WordApp.Documents.Add(ref fileName, ref newTemplate, ref docType, ref isVisible);<br />
 WordApp.Visible = false;<br />
 ActiveDoc.Activate();<br />
<br />
 //add text to bookmarks within the current word app<br />
 object oWhat = Word.WdGoToItem.wdGoToBookmark;<br />
 <br />
 object oName = "name";<br />
 ActiveDoc.GoTo(ref oWhat, ref oMissing, ref oMissing, ref oName).Text = txtName.Text;<br />
<br />
 oName = "val1";<br />
 ActiveDoc.GoTo(ref oWhat, ref oMissing, ref oMissing, ref oName).Text = txtValue1.Text;<br />
<br />
 oName = "val2";<br />
 ActiveDoc.GoTo(ref oWhat, ref oMissing, ref oMissing, ref oName).Text = txtValue2.Text;<br />
			<br />
//print 1 copy of active document<br />
object xcopies = 1;<br />
 ActiveDoc.PrintOut(ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref<br />
  oMissing,ref oMissing,ref oMissing,ref xcopies,ref oMissing,ref oMissing,ref<br />
  oMissing,ref oMissing,ref oMissing,ref oMissing,ref oMissing,ref<br />
  oMissing,ref oMissing,ref oMissing);<br />
<br />
 //quit word application after merge & print<br />
 object oSaveChanges = 0;<br />
 //WordApp.Quit(ref oSaveChanges, ref oMissing, ref oMissing);<br />
}<br />


Now this works, and diligently takes values and pumps them into the word document template at a specified bookmark - but yes your right, this isnt really mail merging - as it uses bookmarks and not Word FILL-IN mail merge fields, which presents problems when document templates change etc etc, so I really need proper mailmerging - i.e find all FILL fields in XYZ templates and put VALUE123 in there

Has anybody done anything similar using mailmerge fields, and if so, how on earth do you do it?

p.s. I have tried messing around with Word.WdGoToItem.wdGoToField & Word.WdGoToDirection.wdGoToNext to no avail

Thanks muchly in Advance

Mr Eyes

EDIT :
There is a sample on the MS website, but its a no go, as it doesnt even compile
http://support.microsoft.com/default.aspx?scid=kb;en-us;Q301659
GeneralRe: Mail Merging with Word & C# Pin
Eric Gunnerson (msft)5-Dec-02 17:49
Eric Gunnerson (msft)5-Dec-02 17:49 
GeneralRe: Mail Merging with Word & C# Pin
MikeDoerfler6-Dec-02 6:19
MikeDoerfler6-Dec-02 6:19 
Generalvertically input text Pin
jirigala4-Dec-02 23:35
jirigala4-Dec-02 23:35 
GeneralRetrieving data from SQL server... Pin
$iva4-Dec-02 22:55
$iva4-Dec-02 22:55 
GeneralRe: Retrieving data from SQL server... Pin
Christian Graus4-Dec-02 23:33
protectorChristian Graus4-Dec-02 23:33 
GeneralRe: Retrieving data from SQL server... Pin
Kannan Kalyanaraman5-Dec-02 1:14
Kannan Kalyanaraman5-Dec-02 1:14 
GeneralC# and Windows'98 Pin
julych4-Dec-02 22:23
julych4-Dec-02 22:23 
GeneralRe: C# and Windows'98 Pin
Christian Graus4-Dec-02 23:33
protectorChristian Graus4-Dec-02 23:33 
GeneralRe: C# and Windows'98 Pin
Rickard Andersson205-Dec-02 0:49
Rickard Andersson205-Dec-02 0:49 
GeneralRe: C# and Windows'98 Pin
djkno35-Dec-02 1:31
djkno35-Dec-02 1:31 
GeneralRe: C# and Windows'98 Pin
Rickard Andersson205-Dec-02 1:57
Rickard Andersson205-Dec-02 1:57 
GeneralRe: C# and Windows'98 Pin
djkno35-Dec-02 12:05
djkno35-Dec-02 12:05 
GeneralRe: C# and Windows'98 Pin
Rickard Andersson205-Dec-02 20:42
Rickard Andersson205-Dec-02 20:42 
GeneralRe: C# and Windows'98 Pin
Christian Graus5-Dec-02 6:33
protectorChristian Graus5-Dec-02 6:33 
Generalsimple connection to Access database in c# Pin
Abu Atwan4-Dec-02 13:36
Abu Atwan4-Dec-02 13:36 
GeneralRe: simple connection to Access database in c# Pin
Nick Parker4-Dec-02 17:55
protectorNick Parker4-Dec-02 17:55 
GeneralC# Office Addins Pin
Chris Ormerod4-Dec-02 13:27
Chris Ormerod4-Dec-02 13:27 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.