Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 06-01-2017, 02:53 AM
DavidTheToad DavidTheToad is offline Moving to a particular word in a document Windows XP Moving to a particular word in a document Office 2007
Novice
Moving to a particular word in a document
 
Join Date: Nov 2013
Posts: 15
DavidTheToad is on a distinguished road
Default Moving to a particular word in a document

This is about editing large literary documents.

Using a macro which I've written I can find many of the punctuation and other errors and list them on a summary document. This summary document gives the word number where a 30 word extract starts and it prints the extract.

A typical entry might read

"1675 the baby through the Tedy Bear out of the pramm..(and so on)"

It would help me a lot if I could create a new macro, enter the number 1675 and be taken to that bit of the document around words(1675).

I can't seem to find a suitable instruction. I tried things like words(p).show, but I can't figure out what I need.

Any help will be gratefully received
Reply With Quote
  #2  
Old 06-01-2017, 02:12 PM
dwirony dwirony is offline Moving to a particular word in a document Windows 7 64bit Moving to a particular word in a document Office 2003
Advanced Beginner
 
Join Date: Oct 2016
Posts: 49
dwirony will become famous soon enough
Default

Sorry if I'm not following - but why can't you just use the Find tool (Ctrl + F) and go to the words that way?
Reply With Quote
  #3  
Old 06-01-2017, 04:54 PM
eduzs eduzs is offline Moving to a particular word in a document Windows 10 Moving to a particular word in a document Office 2010 32bit
Expert
 
Join Date: May 2017
Posts: 262
eduzs is on a distinguished road
Default

Selection.WholeStory

With Selection.Find

.Text = "1675"
.Execute

End With
__________________
Backup your original file before doing any modification.
Reply With Quote
  #4  
Old 06-01-2017, 08:15 PM
gmayor's Avatar
gmayor gmayor is offline Moving to a particular word in a document Windows 10 Moving to a particular word in a document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,103
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 of
Default

You need to modify your original macro to bookmark the problem locations with a bookmark name e.g bm1675. You can then easily go to that bookmark.
__________________
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
  #5  
Old 06-02-2017, 12:04 PM
DavidTheToad DavidTheToad is offline Moving to a particular word in a document Windows XP Moving to a particular word in a document Office 2007
Novice
Moving to a particular word in a document
 
Join Date: Nov 2013
Posts: 15
DavidTheToad is on a distinguished road
Default Bookmarks

Graham,

Yes, I can see this would work OK, but ...

I am looking through my Mackenzie and Martins but I cannot find how to add a bookmark from the macro. (Also, although I never work with the original scripts, it would be good if I could rub out the bookmarks once I've finished with them)
Reply With Quote
  #6  
Old 06-02-2017, 08:14 PM
gmayor's Avatar
gmayor gmayor is offline Moving to a particular word in a document Windows 10 Moving to a particular word in a document Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,103
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 of
Default

Without seeing your macro it is difficult to advise how to add to it. Basically you set a bookmark to the range that you have found as you add it to your log.

To go to the bookmark - let's assume you have added bookmarks bm1 to bm10 i.e a number following 'bm'. Then the following macro will prompt for a number and then select the numbered bookmark and delete the bookmark (but not its content).

Code:
Sub GetBM()
Dim sBM As String
    On Error GoTo lbl_Exit
    sBM = InputBox("Go to which bookmark number")
    With ActiveDocument.Bookmarks("bm" & sBM)
        .Range.Select
        .Delete
    End With
lbl_Exit:
    Exit Sub
End Sub
__________________
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
  #7  
Old 06-03-2017, 03:13 AM
DavidTheToad DavidTheToad is offline Moving to a particular word in a document Windows XP Moving to a particular word in a document Office 2007
Novice
Moving to a particular word in a document
 
Join Date: Nov 2013
Posts: 15
DavidTheToad is on a distinguished road
Default Thank you

Thanks for the code. I also found a lot of stuff in the Microsoft archives, so I think I'll be able to manage this now. I'm grateful for your advice.
Reply With Quote
Reply

Tags
editing



Similar Threads
Thread Thread Starter Forum Replies Last Post
Moving to a particular word in a document moving charts around a word document rich_cirillo Word 1 05-13-2014 07:10 PM
Moving Quick Parts with the document derohanes Word 4 10-23-2013 09:30 PM
Moving to a particular word in a document Adding and Moving parts of a document in Word PauledInAction Word 4 07-13-2012 02:38 PM
Moving to a particular word in a document Moving a Long Document clpix Word 1 01-14-2010 08:55 PM
problem moving text to blank document carolanshaw Word 0 03-23-2009 08:45 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 03:16 AM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft