Microsoft Office Forums

Go Back   Microsoft Office Forums > >

 
 
Thread Tools Display Modes
Prev Previous Post   Next Post Next
  #6  
Old 05-19-2016, 05:29 AM
gmayor's Avatar
gmayor gmayor is offline How to insert text before bookmark ? Windows 10 How to insert text before bookmark ? Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,144
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

OK I see what you mean. The following should address it.

Code:
Dim oRng As Range
Dim oOriginal As Range
    Set oOriginal = ActiveDocument.Bookmarks("MybookmarkName").Range
    Set oRng = ActiveDocument.Bookmarks("MybookmarkName").Range
    oRng.Collapse 1
    oRng.Text = "toto"
    oOriginal.start = oRng.End
    oOriginal.Bookmarks.Add "MybookmarkName"
or alternatively
Code:
Dim oRng As Range
Dim oOriginal As Range
Dim sText As String: sText = "toto"
    Set oRng = ActiveDocument.Bookmarks("MybookmarkName").Range
    oRng.InsertBefore sText
    oRng.MoveStart Count:=Len(sText)
    oRng.Bookmarks.Add "MybookmarkName"
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
 



Similar Threads
Thread Thread Starter Forum Replies Last Post
Replicating Insert Hyperlink-Bookmark function Marrick13 Word VBA 0 02-05-2016 01:27 PM
How to insert text before bookmark ? Is there anyway I can insert an easy bookmark in word? BayhDole Word 2 07-21-2015 08:43 PM
How to insert text before bookmark ? Open header to insert text into bookmark Amapola188 Word VBA 3 07-12-2012 05:16 PM
How to insert text before bookmark ? Word 2003 - IncludeText Does Not Include Bookmark Text if in a Form Text Control skarden Word 1 12-12-2011 10:39 PM
How to insert text before bookmark ? VBA to insert Bookmark rockwellsba Word VBA 2 05-31-2011 01:07 AM

Other Forums: Access Forums

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