![]() |
#1
|
|||
|
|||
![]()
Hi,
Here is what i found : Code:
ActiveDocument.Bookmarks("MybookmarkName").Range.InsertBefore ("toto") The function i am looking for is to write before the bookmark (meaning out of bookmark range). Any hints ? BR, Vincent |
#2
|
||||
|
||||
![]()
It is more useful to write IN the bookmark, which enables the content to be changed, for which you can look at the FillBM function on my web site.
The code you quote Code:
ActiveDocument.Bookmarks("MybookmarkName").Range.InsertBefore "toto"
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
![]()
Indeed it is usefull to write IN the bookmark but it is not what i am seeking for today.
I want to add a text BEFORE the bookmark, no link between them. Any hints ? |
#4
|
||||
|
||||
![]()
As I asked, what hints do you want? The code you posted will do that. I merely removed the brackets which were superfluous.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#5
|
|||
|
|||
![]()
When you call my code here is the result :
[totoMyTextInsideMyBookmark] I want : toto[MyTextInsideMyBookmark] I hope my problem appears now ![]() |
#6
|
||||
|
||||
![]()
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" 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 |
#7
|
|||
|
|||
![]()
OMFG you are too strong. Your help is very much apreciated
![]() This topic is solved. |
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Replicating Insert Hyperlink-Bookmark function | Marrick13 | Word VBA | 0 | 02-05-2016 01:27 PM |
![]() |
BayhDole | Word | 2 | 07-21-2015 08:43 PM |
![]() |
Amapola188 | Word VBA | 3 | 07-12-2012 05:16 PM |
![]() |
skarden | Word | 1 | 12-12-2011 10:39 PM |
![]() |
rockwellsba | Word VBA | 2 | 05-31-2011 01:07 AM |