Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 11-09-2020, 08:56 PM
rekent rekent is offline Insert Comments from List for Whole Document and for Only Selected Portion of Document Windows 7 64bit Insert Comments from List for Whole Document and for Only Selected Portion of Document Office 2010
Novice
Insert Comments from List for Whole Document and for Only Selected Portion of Document
 
Join Date: May 2014
Posts: 23
rekent is on a distinguished road
Default

Would it be possible to create the bookmark for DocumentToCheck dynamically within the code based on the preceding and following headings? I need to be able to run this without the document including special elements, instead just having the document's normal formatting and structure.



Could the word LIST in uppercase be found, the list ABSTRACT in uppercase be found, a range defined from immediately following the last character of LIST to immediately preceding the first character of ABSTRACT, and then add the bookmark to that range? (Not that I know how to write the code to define the range that I just suggested...)

Edit: I think this code should achieve what I describe above (searching up from the bottom of the document), but VBE is not cooperating at the moment.

Code:
Dim startPosition As Long, endPosition As Long, listRange As Range

Selection.EndKey Unit:=wdStory

With Selection.Find
        .ClearFormatting
        .Forward = Flase
        .Format = True
        .MatchWholeWord = True
        .MatchCase = True
        .MatchWildcards = False
        .Execute FindText:=uCase("ABSTRACT")

endPosition = Selection.Range.Start

With Selection.Find
        .ClearFormatting
        .Forward = False
        .Format = True
        .MatchWholeWord = True
        .MatchCase = True
        .MatchWildcards = False
        .Execute FindText:=uCase("LIST")

startPosition = Selection.Range.End

listRange.SetRange Start:=startPosition, End:=endposition
ActiveDocument.Bookmarks.Add Name:="ListArea", Range:=listRange

Last edited by rekent; 11-10-2020 at 02:51 PM.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Reveal portion of document based on dropdown selection chappeja Word VBA 1 03-27-2019 08:36 PM
Insert Comments from List for Whole Document and for Only Selected Portion of Document Renumber document at annex portion of document jeffreybrown Word 3 02-14-2019 05:53 AM
How do you add XML Schema Tags to Certain portion of a Word Document? Anishgirijan Word VBA 0 02-08-2017 10:38 PM
Insert Comments from List for Whole Document and for Only Selected Portion of Document How can I link a portion of a word document to another word document and have it auto update? __Data Word 1 06-30-2015 11:03 PM
Save as PDF only saves portion of document pandro Word 0 10-08-2014 06:54 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 05:31 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