Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #2  
Old 04-29-2021, 04:01 AM
Guessed's Avatar
Guessed Guessed is offline inserting a custom property field in a bookmark Windows 10 inserting a custom property field in a bookmark Office 2016
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,176
Guessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant futureGuessed has a brilliant future
Default

I'm sure there will be a more elegant way to do this but this is my first attempt
Code:
Sub DemoReplaceBookmark()
  Dim aRng As Range, aField As Field
  Set aRng = ActiveDocument.Bookmarks("aaa").Range
  Set aField = ActiveDocument.Fields.Add(Range:=aRng, Text:="DocProperty Title")
  aRng.InsertBefore "text in front"
  aRng.End = aField.Result.End
  aRng.InsertAfter "text at end"
  'aRng.Select
  ActiveDocument.Bookmarks.Add Name:="aaa", Range:=aRng
End Sub
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
 

Tags
bookmark;content control, field



Similar Threads
Thread Thread Starter Forum Replies Last Post
inserting a custom property field in a bookmark Updating a custom property in the header JonFleming Word VBA 9 02-09-2016 05:22 AM
inserting a custom property field in a bookmark Update Custom Document Property in Template Byron Polk Word VBA 10 08-19-2014 07:19 AM
Custom Document Property Lost From Template bhaughey Word 8 03-05-2013 02:11 PM
Link Watermark to custom property kerend Word 0 04-08-2012 05:03 AM
inserting a custom property field in a bookmark QuickParts - custom document property untttt Word 2 06-09-2011 05:24 PM

Other Forums: Access Forums

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