Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-04-2017, 04:06 AM
DavidTheToad DavidTheToad is offline Inserting a bookmark Windows XP Inserting a bookmark Office 2007
Novice
Inserting a bookmark
 
Join Date: Nov 2013
Posts: 15
DavidTheToad is on a distinguished road
Default Inserting a bookmark

My macro chooses a number of extracts from a large document, each extract is 30 words long. It writes them on a second document. All this works fine.



I now want to add a bookmark at the start of each extract. I have taken an example from the microsoft library so that the relevant parts of the code are

Code:
For n = 1 to 10   ' Number of extracts
bkmk="bm" & n
z=Rnd
mx=(upperbound - lowerbound +1)*Rnd + lowerbound
m=Int(mx)
sorsDoc.Words(m).Bookmarks.Add Name:="bkmk" 
'The above from https://msdn.microsoft.com/en-us/library/office/ff197253.aspx
[Some other instructions]
next   'Next n
The problem is that when I come to look at sorsDoc after the macro has run, I can only see a single bookmark instead of ten of them.
Reply With Quote
  #2  
Old 06-04-2017, 05:45 PM
Guessed's Avatar
Guessed Guessed is offline Inserting a bookmark Windows 10 Inserting a bookmark Office 2013
Expert
 
Join Date: Mar 2010
Location: Canberra/Melbourne Australia
Posts: 4,166
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

You are creating a bookmark named "bkmk" instead of creating a bookmark named bm#

Get rid of the quote marks on the line that should read
Code:
sorsDoc.Words(m).Bookmarks.Add Name:=bkmk
__________________
Andrew Lockton
Chrysalis Design, Melbourne Australia
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Find Bookmark, move to bookmark, execute code, repeat raymm3852 Word VBA 10 04-15-2016 06:21 PM
Userform without inserting Bookmark text mktate Word VBA 8 12-31-2015 01:11 PM
Inserting a bookmark Bookmark not replaced when inserting but to lower right corner of image newbieX Word VBA 6 11-20-2015 02:03 PM
Inserting a bookmark Bookmark Not Showing Bookmark RegAudit Word 6 03-16-2015 11:08 PM
vba to go to next bookmark megatronixs Word VBA 2 06-08-2014 09:53 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 01:20 PM.


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