Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-14-2016, 05:27 PM
raymm3852 raymm3852 is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Novice
Find Bookmark, move to bookmark, execute code, repeat
 
Join Date: Apr 2016
Posts: 6
raymm3852 is on a distinguished road
Question Find Bookmark, move to bookmark, execute code, repeat

Newbie question.

Code is:
Sub EnterTranscriptPages()
While ActiveDocument.Bookmarks.Exists("TranscriptPage") = True
Selection.Find.Execute
Selection.NextField.Select
Selection.Fields.Update
Wend
End Sub

Problem is I need to see the field so I can read the paragraphs around the field so I can know what info to enter into the update box.



Now it runs the code, shows me each input box, but doesn't change the screen from the starting point.
Reply With Quote
  #2  
Old 04-14-2016, 10:07 PM
gmayor's Avatar
gmayor gmayor is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,105
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

What EXACTLY is it that you think this code is trying to achieve?
What sort of 'fields' are involved.
If you want to call bookmarks and go to them then call them by name.
If you want to move between fields F11 is pre configured to do that.
If you want to change the contents of a bookmark then see the FillBM function you can find on my web site.
__________________
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
  #3  
Old 04-15-2016, 04:40 AM
raymm3852 raymm3852 is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Novice
Find Bookmark, move to bookmark, execute code, repeat
 
Join Date: Apr 2016
Posts: 6
raymm3852 is on a distinguished road
Default

Thank you for attending to my question.

I want the code to
move me to each instance of the bookmark "TranscriptPage"
Open a box asking for the page reference
allow me to look up the page reference for the quote, then enter the page reference into the box
then move to the next instance of the bookmark "TranscriptPage"
and repeat until no further instance of the bookmark

The fields are "ASK" fields.

The code does call the bookmarks by name, the name of each bookmark where page numbers are required is "TranscriptPage". There are multiple instances of bookmarks names "TranscriptPage".

Yes, F11 will move me to the bookmark, but F11 won't open the ASK box and let me enter the page number, then insert the page number into the document, then repeat with next spot.

I don't want to change the contents of the bookmark. The bookmark is where a page reference is needed. The ASK field gathers the page number and enters it into the document.



I hope that explains what I'm trying to do.
Reply With Quote
  #4  
Old 04-15-2016, 04:46 AM
raymm3852 raymm3852 is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Novice
Find Bookmark, move to bookmark, execute code, repeat
 
Join Date: Apr 2016
Posts: 6
raymm3852 is on a distinguished road
Default Attachment

See attachment
Attached Images
File Type: jpg Transcript.JPG (15.1 KB, 25 views)
Reply With Quote
  #5  
Old 04-15-2016, 06:30 AM
gmaxey gmaxey is offline Find Bookmark, move to bookmark, execute code, repeat Windows 7 32bit Find Bookmark, move to bookmark, execute code, repeat Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Try this:

Code:
Sub ScratchMacro()
'A basic Word macro coded by Greg Maxey
Dim oFld As Field
Dim oRng As Range
  For Each oFld In ActiveDocument.Range.Fields
    If oFld.Type = wdFieldAsk Then
      If InStr(oFld.Code, "TranscriptPage") > 0 Then
        Set oRng = oFld.Code
        oRng.Collapse wdCollapseStart
        oRng.Select
        oFld.Update
      End If
    End If
  Next
lbl_Exit:
  Exit Sub
End Sub
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #6  
Old 04-15-2016, 09:22 AM
raymm3852 raymm3852 is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Novice
Find Bookmark, move to bookmark, execute code, repeat
 
Join Date: Apr 2016
Posts: 6
raymm3852 is on a distinguished road
Default

That works, thank you so very much, you have solved a problem for me and given me a macro to study for further use. Well done.

I did notice that the page number at the bottom doesn't update, it stays the same throughout. Is there an easy fix for this?
Reply With Quote
  #7  
Old 04-15-2016, 09:37 AM
gmaxey gmaxey is offline Find Bookmark, move to bookmark, execute code, repeat Windows 7 32bit Find Bookmark, move to bookmark, execute code, repeat Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Try adding ActiveDocument.Fields.Update at before the lbl_Exit line.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #8  
Old 04-15-2016, 09:57 AM
raymm3852 raymm3852 is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Novice
Find Bookmark, move to bookmark, execute code, repeat
 
Join Date: Apr 2016
Posts: 6
raymm3852 is on a distinguished road
Default

Thank you for your suggestion.

I copied ActiveDocument.Fields.Update and put it before the lbl_Exit line so the code was:

Dim oFld As Field
Dim oRng As Range
For Each oFld In ActiveDocument.Range.Fields
If oFld.Type = wdFieldAsk Then
If InStr(oFld.Code, "TranscriptPage") > 0 Then
Set oRng = oFld.Code
oRng.Collapse wdCollapseStart
oRng.Select
oFld.Update
End If
End If
Next
ActiveDocument.Fields.Update
lbl_Exit:
Exit Sub
End Sub

The bar at the bottom of the page still did not update to show the current page name.

Also the current document contains 7 instances of "TranscriptPage". The macro goes through the document once allowing me to enter the pages numbers, then the macro repeats showing the ASK box again, starting at the beginning, showing each sequentially to the last one.
Reply With Quote
  #9  
Old 04-15-2016, 10:29 AM
gmaxey gmaxey is offline Find Bookmark, move to bookmark, execute code, repeat Windows 7 32bit Find Bookmark, move to bookmark, execute code, repeat Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Yeah, that was a bad idea. That is causing all the Ask fields to update again. What "bar" at the bottom of the page are you talking about?
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
  #10  
Old 04-15-2016, 10:58 AM
raymm3852 raymm3852 is offline Find Bookmark, move to bookmark, execute code, repeat Windows 10 Find Bookmark, move to bookmark, execute code, repeat Office 2016
Novice
Find Bookmark, move to bookmark, execute code, repeat
 
Join Date: Apr 2016
Posts: 6
raymm3852 is on a distinguished road
Default

See attachment.

I think it is called the Status Bar.
Attached Images
File Type: jpg Bar at bottom.JPG (19.1 KB, 18 views)
Reply With Quote
  #11  
Old 04-15-2016, 06:21 PM
gmaxey gmaxey is offline Find Bookmark, move to bookmark, execute code, repeat Windows 7 32bit Find Bookmark, move to bookmark, execute code, repeat Office 2010 (Version 14.0)
Expert
 
Join Date: May 2010
Location: Brasstown, NC
Posts: 1,429
gmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the roughgmaxey is a jewel in the rough
Default

Well here the status bar updates to reflect whatever page number has the selection.
__________________
Greg Maxey
Please visit my web site at http://www.gregmaxey.com/
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Iterating through tables to find a bookmark bgmsd Word VBA 12 06-08-2015 10:09 AM
Find Bookmark, move to bookmark, execute code, repeat Bookmark Not Showing Bookmark RegAudit Word 6 03-16-2015 11:08 PM
Find Bookmark, move to bookmark, execute code, repeat Move shape to bookmark location Byron Polk Word VBA 4 08-07-2014 03:21 AM
vba to go to next bookmark megatronixs Word VBA 2 06-08-2014 09:53 PM
Find Bookmark, move to bookmark, execute code, repeat Find and Execute cksm4 Word VBA 1 10-22-2011 11:36 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 06:22 PM.


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