Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #1  
Old 06-15-2020, 09:13 AM
bsforza bsforza is offline Replace Merge Field with Conditional If Windows 10 Replace Merge Field with Conditional If Office 2019
Novice
Replace Merge Field with Conditional If
 
Join Date: Jun 2020
Posts: 1
bsforza is on a distinguished road
Default Replace Merge Field with Conditional If

Hi, I'm having some trouble figuring out how to replace a basic Merge field with a conditional statement. I'm looking to, using macros, replace something like:
Code:
{ MERGEFIELD "A" }
with:
Code:
{ IF {MERGEFIELD "A"} = "Yes", {MERGEFIELD "T"}{MERGEFIELD "F"}}
This is what I've got going already:
Code:
Sub Ex()
Dim oFld As Field
For Each oFld In ActiveDocument.Fields
  With oFld
    If .Type = wdFieldMergeField Then
      If Trim(Replace(Replace(.Code, "MERGEFIELD", ""), Chr(34), "")) = "A" Then
         // Replace Merge Field with Conditional - Help
        .Update
      End If
    End If
  End With
Next
End Sub

Reply With Quote
 

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Replace Merge Field with Conditional If Replace specific word inside a table in the Header with Merge field Turin74 Word VBA 3 06-06-2019 06:17 PM
Replace Merge Field with Conditional If Form with conditional field. Asuryan33 Word VBA 6 10-18-2017 03:45 PM
Replace Merge Field with Conditional If Conditional Field CKTisdale Word 1 04-10-2015 02:41 PM
Replace Merge Field with Conditional If Conditional merge fields in mail merge Aude Mail Merge 1 01-06-2012 07:38 PM
Replace Merge Field with Conditional If Replace all occurrences of one merge field with plain text blankenthorst Mail Merge 5 07-01-2011 05:18 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 09:45 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft