![]() |
|
|
|
#1
|
||||
|
||||
|
I'm not seeing the issue you describe when using my macro in that test document. It had 5 bookmarks before and after running the macro.
The code is not deleting and re-adding a bookmark, it is just adding a footnote anchor at the starting position of a bookmark exists. If the bookmark encloses a range, then the footnote will be inside the bookmark. If the bookmark is a zero length range then the footnote gets added after the bookmark.
__________________
Andrew Lockton Chrysalis Design, Melbourne Australia |
|
#2
|
|||
|
|||
|
Thanks Guessed for your reply. Well, I have failed.
![]() Here a simpler macro. Code:
Option Explicit Sub BMTest() Dim tmp As String tmp = "2021" WB "BM1", tmp tmp = "52" WB "BM2", tmp tmp = "10x" WB "BM3", tmp tmp = "2021" WB "BM4", tmp tmp = "52" WB "BM5", tmp tmp = "10x" WB "BM6", tmp End Sub Public Sub WB(ByVal BName As String, ByVal inhalt As String) If ActiveDocument.Bookmarks.Exists(BName) Then Dim r As Range Set r = ActiveDocument.Bookmarks(BName).Range r.Text = inhalt ActiveDocument.Bookmarks.Add BName, r Else Debug.Print "Bookmark not found: " & BName End If End Sub In word, copy the following and insert the bookmarks Code:
/* This works (note the space)*/ KTP.EG.[BM1] [BM2] [BM3] /* This fails */ KTP.EG.[BM4][BM5][BM6] Code:
KTP.EG.2021 52 10x KTP.EG.10x |
|
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
Footnote references in the footnote section losing their style when cut+pasted from same doc
|
emblaw | Word | 4 | 12-08-2020 06:23 AM |
Removing line break and indentation between footnote number and footnote text in Word
|
jaanross | Word | 5 | 02-06-2020 12:04 AM |
| REf Fields show Bookmark whole cell when Bookmark is created by code. | pmcpowell | Word VBA | 2 | 11-16-2019 07:05 PM |
Adding footnote number as part of footnote text
|
NoCalScribe | Word VBA | 3 | 07-15-2019 07:20 PM |
| Find Bookmark, move to bookmark, execute code, repeat | raymm3852 | Word VBA | 10 | 04-15-2016 06:21 PM |