mergefield

Change MergeField to text only

随声附和 提交于 2020-01-06 05:54:30
问题 I need to replace text into MergeField and do it simply text. I found question on the topic. It works for me. This code changes the text, but leaves the field as MergeField . And other question that change MergeField to text. But if there are several such fields in one line, the second one will be deleted. At this point, I've tweaked the code from the first link a bit. What do I need to add to change MergeField to text? string sourceFile = @"C:\Users\Owl\Desktop\Template.docm"; string

How do I insert a mergefield into an If..else statement in VBA using Word MailMerge?

可紊 提交于 2019-12-18 09:26:22
问题 The below macro will input the field heading followed by the field value. The If statement should check the value of the field and if its greater than 30 the actual value is given, otherwise a zero. Instead of the value appearing if it's true, I just get the actual text I've typed, not it's value. Sub Macro1() Dim doc As Word.Document Dim dtField As Word.MailMergeDataField Dim sFieldName As String Dim sFieldActualName As String Dim j As Integer Set doc = ActiveDocument j = 1 For Each dtField

Replace MergeFields in a Word 2003 document and keep style

帅比萌擦擦* 提交于 2019-12-10 09:02:25
问题 I've been trying to create a library to replace the MergeFields on a Word 2003 document, everything works fine, except that I lose the style applied to the field when I replace it, is there a way to keep it? This is the code I'm using to replace the fields: private void FillFields2003(string template, Dictionary<string, string> values) { object missing = Missing.Value; var application = new ApplicationClass(); var document = new Microsoft.Office.Interop.Word.Document(); try { // Open the file

Replace MergeFields in a Word 2003 document and keep style

眉间皱痕 提交于 2019-12-05 12:07:42
I've been trying to create a library to replace the MergeFields on a Word 2003 document, everything works fine, except that I lose the style applied to the field when I replace it, is there a way to keep it? This is the code I'm using to replace the fields: private void FillFields2003(string template, Dictionary<string, string> values) { object missing = Missing.Value; var application = new ApplicationClass(); var document = new Microsoft.Office.Interop.Word.Document(); try { // Open the file foreach (Field mergeField in document.Fields) { if (mergeField.Type == WdFieldType.wdFieldMergeField)

How do I insert a mergefield into an If..else statement in VBA using Word MailMerge?

亡梦爱人 提交于 2019-11-29 16:26:29
The below macro will input the field heading followed by the field value. The If statement should check the value of the field and if its greater than 30 the actual value is given, otherwise a zero. Instead of the value appearing if it's true, I just get the actual text I've typed, not it's value. Sub Macro1() Dim doc As Word.Document Dim dtField As Word.MailMergeDataField Dim sFieldName As String Dim sFieldActualName As String Dim j As Integer Set doc = ActiveDocument j = 1 For Each dtField In doc.MailMerge.DataSource.DataFields sFieldActualName = doc.MailMerge.DataSource.FieldNames(j).Name

Mailmerge dynamic hyperlink fields lost after save/reload of document - Word 2010

久未见 提交于 2019-11-28 09:28:17
问题 I have a problem where using dynamic hyperlinks in field codes works fine when I create a document, but when save and later reload it the links are replaced with text from the original recordset. The field code I am using is: { HYPERLINK { MERGEFIELD "Fieldname" } \* MERGEFORMAT } After saving then reloading the document this becomes similar to: { HYPERLINK "http://www.example.com" } I am merging to HTML email. I have been unable to get this to successfully work after saving. This is a

Position cursor at start/end of Word document

老子叫甜甜 提交于 2019-11-27 07:39:37
问题 We are manipulating our Word 2007 documents from .Net using Word Interop. Mostly doing stuff with fields as in: For Each f In d.Fields f.Select() //do stuff with fields here Next This leaves the last field in the document selected. So, for the sake of neatness we would like to position the cursor at the end of the document (or even the start would be OK). Googling for the answer doesn't throw up much ... the nearest I can get seems to be suggesting we need to involve ourselves with ranges or