mailmerge

Mail Merge (Excel to Word) using C#

自闭症网瘾萝莉.ら 提交于 2019-12-08 03:46:27
I was wondering if anybody knew how to do a mail merge using an Excel file as a datasource, to fill in fields on a Word template? I wish to use the interop for Word if i could...but am having a few difficulties finding code for this. Does anybody have any syntax for this? Thank you in advance. A very useful method for learning how to automate specific actions in MS Word is to actually perform the action manually with 'Record Macro' enabled. Once you have the VBA macro its easy enough to convert this to VB.NET or C# that uses interop. I tend to tweak the VBA first manually in Word so I can then

Access / Word 2010 VBA Mail Merge Tries to Open [Foldername].mdb Instead of ACCDB Source

拈花ヽ惹草 提交于 2019-12-07 18:51:33
问题 We are attempting to automate a mail merge process from within Access - upon clicking a button, VBA runs that specifies the current database (an accdb) as the data source and runs SQL, per the code below: 'Set up Word Dim objWord As Object Set objWord = CreateObject("Word.Application") 'Make visible, open specified doc to merge With objWord .Visible = True .Documents.Open strDocName End With 'Set the data source path Dim docPath As String docPath = CurrentProject.Path & "\" & CurrentProject

copying openXML image from one document to another

梦想与她 提交于 2019-12-07 13:11:23
问题 We have conditional Footers that INCLUDETEXT based on the client: IF $CLIENT = "CLIENT1" "{INCLUDETEXT "CLIENT1HEADER.DOCX"}" "" Depending on our document, there could be a varying amount of IF/ELSE , and these all work correctly for merging the correct files in the correct place. However, some of these documents may have client specific images/branding, which also need to be copied across from the INCLUDETEXT file. Below is the method that is called to replace any Picture elements that exist

Mail merge started by VBA in Access let Word open Database again

心已入冬 提交于 2019-12-07 10:08:27
问题 I'm working on a Access database which generates some mails with mail merge called from VBA code in the Access database. The problem is that if I open a new Word document and start the mail merge (VBA), Word opens the same Access database (which is already open) to get the data. Is there any way to prevent this? So that the already opened instance of the database is used? After some testing I get a strange behavior: If I open the Access database holding the SHIFT-Key the mail merge does not

How to split a mail merge and save files with a merge field as the name

醉酒当歌 提交于 2019-12-06 09:19:19
问题 I have a bunch of mail merge templates setup, when I merge the documents I want to split the results into separate files each one with a name based on the merge field “FileNumber”. The code I have currently is: Sub splitter() ' Based on a macro by Doug Robbins to save each letter created by a mailmerge as a separate file. ' With help from http://www.productivitytalk.com/forums/topic/3927-visual-basic-question-for-merge-fields/ Dim i As Integer Dim Source As Document Dim Target As Document Dim

Add CC and BCC with Mail Merge

好久不见. 提交于 2019-12-06 07:24:05
问题 I am trying to add the cc function to a mail merge. In other words, I not only need to personalize the emails to different email addresses. I would also like each email to be include a CC that shows the same email to multiple recipients. Example: the same email to John Doe can be automatically cc'd to his manager. I tried adding , and ; as well as merging two cells in excel with the addresses and got errors. I also read an article that shows how to send attachments to multiple recipients and

copying openXML image from one document to another

前提是你 提交于 2019-12-05 18:54:10
We have conditional Footers that INCLUDETEXT based on the client: IF $CLIENT = "CLIENT1" "{INCLUDETEXT "CLIENT1HEADER.DOCX"}" "" Depending on our document, there could be a varying amount of IF/ELSE , and these all work correctly for merging the correct files in the correct place. However, some of these documents may have client specific images/branding, which also need to be copied across from the INCLUDETEXT file. Below is the method that is called to replace any Picture elements that exist in the IEnumerable<Run> that is copied from the Source document to the Target document. The image is

Mail Merge into word

冷暖自知 提交于 2019-12-05 17:42:56
The Best way to create labels is using existing industry standard tools , such as Microsoft word. How do you execute this and set up the shipping labels ? I am unsure how to map merge fields against data grid view columns. This is the code I have so far: // Create a new empty document. DocumentModel document = new DocumentModel(); // Add document content. document.Sections.Add( new Section(document, new Paragraph(document, new Field(document, FieldType.MergeField, "FullName")))); // Save the document to a file and open it with Microsoft Word. document.Save("TemplateDocument.docx"); // If

Compile ASPX in WinForms App

孤街浪徒 提交于 2019-12-05 17:39:45
I'm writing a WinForms application that sends email messages (like a mail merge). I'd like to use ASP.Net's rendering engine to render the HTML bodies of the messages. What's the simplest way to get the rendered output of a single ASPX page without the entire ASP.Net runtime? To make things harder, I'd prefer to compile the ASPX at runtime so that it can be modified without rebuilding the application. However, this is not a requirement; if it's too difficult, I'll give up on it. Rick Strahl posted an article how to do this at this location: http://www.west-wind.com/presentations/aspnetruntime

How to set the file name of a word document without saving it from c# and automation

橙三吉。 提交于 2019-12-04 03:59:07
问题 I create word documents via automation and mailmerge with office Interop from c# (.net4). The merge works well and the user receives the created document as he desires. So far all is well. The client now requests, that if he tries to save the generated file (via save file dialog), that the filename of the document is already prefilled. I already have tried the obvious things such as setting the Name property of the Document-instance and other properties, I also googled for a solution but up