|
Visual Basic (VB6 and VBA) |
|
Copyright 1999-2001 Christopher Greaves. All rights reserved. Home Page and email to [email protected] |
| If in doubt, record a macro and inspect the entrails! |
Visual Basic Library
This page was last updated on Saturday, November 24, 2001
Public Function BkMkRanges(lngAr() As String, lngToDo() As String) ' Procedure : BkMkRanges ' Description: Identify all text that is *not* bookmarked. ' By: Chris Greaves Inc. ' Inputs: Array of ranges. ' Returns: None. ' Assumes: Nothing ' Side Effects: None. ' Tested: By the calls shown below. ' (1) Identify ranges for all bookmarked text ' (2) Identify total range ' (3) Mark those ranges of (2) not in (1) ' (1) Identify ranges for all bookmarked text ReDim lngAr(2, 0) ' Array to hold ranges of all bookmarked text ReDim lngToDo(2, 0) ' Array to hold those ranges that are not bookmarked ' Identify ranges of all bookmarked text Dim bkmk As Bookmark For Each bkmk In ActiveDocument.Bookmarks lngAr(0, UBound(lngAr, 2)) = Format(bkmk.Range.Start, "0000000000") lngAr(1, UBound(lngAr, 2)) = Format(bkmk.Range.End - 1, "0000000000") lngAr(2, UBound(lngAr, 2)) = bkmk.Name ReDim Preserve lngAr(2, UBound(lngAr, 2) + 1) Next bkmk If UBound(lngAr, 2) > 0 Then ReDim Preserve lngAr(2, UBound(lngAr, 2) - 1) ' Drop the trailing empty item Call SortArray(lngAr, 0, 0, 0) ' Sort ascending key on first column (range.start) ' (2) Identify total range Dim lngStoryStart As Long Dim lngStoryEnd As Long lngStoryStart = ActiveDocument.Range.Start lngStoryEnd = ActiveDocument.Range.End ' (3) mark those ranges of (2) not in (1) Call GetTodo(lngAr, lngStoryStart, lngStoryEnd, lngToDo) Else End If 'Sub TESTBkMkRanges() '' Thje code below builds an array of all bookmark positions, and an array of unmarked text range positions. ' Dim lngAr() As String ' Dim lngToDo() As String ' Call BkMkRanges(lngAr(), lngToDo()) 'End Sub End Function
| We all knew nothing when we started … |
|
Home Page and Contact Information Send email to [email protected]. This page was last updated Monday, November 19, 2001 |