Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 02-09-2023, 06:59 AM
Charles Kenyon Charles Kenyon is offline ...Fields.Add Range:=Selection.Range, Type:=wdFieldIf, Text:=... Windows 11 ...Fields.Add Range:=Selection.Range, Type:=wdFieldIf, Text:=... Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,533
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default


Those braces are not typed text. They are field delimiters that must be inserted as such. You are attempting to build a nested field.

I believe this can be done but do not know, off the top of my head, the construction to do it. I will research this but expect that one of the better coders here will be back with the code before I find the answer.

Off hand, the way I would probably approach this would be to create the field in a document and save it as an AutoText entry. Then I would code to insert the entry.
Using VBA to Insert an AutoText Entry or other Building Block That may not be the best way but it is the way I could create the field quickly using vba without a lot of research. I generally use AutoText/Building Block entries to hold anything requiring complex formatting to be inserted with vba.

In the meantime, I am moving this thread to the Word VBA Forum from the general Word forum.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Distribute text in one cell across a range of cells (overcoming selection.range.cells.count bug) slaycock Word VBA 0 02-18-2017 07:00 AM
...Fields.Add Range:=Selection.Range, Type:=wdFieldIf, Text:=... Working with Selection.range. PRA007 Word VBA 2 02-19-2016 12:52 AM
...Fields.Add Range:=Selection.Range, Type:=wdFieldIf, Text:=... Search and reduce the range of a text selection paik1002 Word VBA 1 12-17-2015 04:51 AM
Selection or Range Tommes93 Word VBA 1 04-10-2014 02:50 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:34 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