-
WSAndrew77
AskWoody LoungerHi Fred,
I’ve not heard of anything like that, but you piqued my interest. The following is a rough attempt at most of the functionality you asked for. The collection colBkData contains all the data you’re looking for. For this example, I just dump it out into a new document, but you could of course put it in a table, or otherwise format it.
Sub GetBookmarkInfo() Dim bk As Bookmark Dim colBkData As Collection Dim col As Collection Dim colRefs As Collection Dim doc As Document Dim strOutput As String Dim k As Long Dim docReport As Document Set colBkData = New Collection Set doc = ActiveDocument doc.Bookmarks.ShowHidden = True For Each bk In doc.Bookmarks Set col = New Collection col.Add Key:="name", Item:=bk.Name col.Add Key:="page", Item:=bk.Range.Information(wdActiveEndPageNumber) col.Add Key:="para-text", Item:=bk.Range.Paragraphs(1).Range.Text Set colRefs = FindRefsToBookmark(bk) col.Add Key:="refs", Item:=colRefs colBkData.Add Item:=col Set col = Nothing Next bk Dim j As Integer For k = 1 To colBkData.count strOutput = strOutput & _ "Bookmark Name: " & colBkData(k)("name") & vbCr & _ "Appears on page: " & colBkData(k)("page") & vbCr & _ "Surrounding text: " & colBkData(k)("para-text") & vbCr If Not colBkData(k)("refs") Is Nothing Then For j = 1 To colBkData(k)("refs").count strOutput = strOutput & _ "Referenced on page: " & colBkData(k)("refs")(j)("page") & vbCr & _ "In the text: " & colBkData(k)("refs")(j)("para-text") & _ vbCr & vbCr Next j End If Next k Set docReport = Documents.Add docReport.Range.InsertAfter strOutput End Sub ' Function FindRefsToBookmark(bk As Bookmark) As Collection Dim f As Field Dim doc As Document Set doc = bk.Parent Dim colRefData As Collection Dim col As Collection Set colRefData = New Collection For Each f In doc.Fields Set col = New Collection If f.Type = wdFieldRef Then If Split(Trim(f.Code))(1) = bk.Name Then f.Select col.Add Key:="page", Item:=Selection.Information(wdActiveEndPageNumber) col.Add Key:="para-text", Item:=Selection.Paragraphs(1).Range.Text colRefData.Add Item:=col End If End If Set col = Nothing Next f If colRefData.count = 0 Then Set FindRefsToBookmark = Nothing Else Set FindRefsToBookmark = colRefData End If End Function
-
WSAndrew77
AskWoody LoungerI think you might need an API call for that (see the thread at post 81357.
It can also be done with a somewhat roundabout technique using an available scripting language that does return the output from system calls (see http://www.perl.com/pub/a/2005/05/26/word_control.html%5B/url%5D for an example of such a technique).
-
WSAndrew77
AskWoody LoungerThe Shell command does not return the output of the command — it returns the command’s PID.
-
WSAndrew77
AskWoody LoungerA simple Case statement would do the trick nicely:
Select Case sUserName Case "User1", "User2", "User3" MsgBox "OK" ' Open document Case Else MsgBox "invalid user" ' Close document End Select
Modifying the allowed users is just a matter of editing the first Case.
-
WSAndrew77
AskWoody LoungerThat article also answers another question recently asked:
[indent]
… which is due when Office 12 hits stores, expected in the second half of next year.
[/indent]
-
WSAndrew77
AskWoody LoungerBasically, Microsoft is dropping proprietary binary file formats for native XML (with images, content, metadata, etc. all zipped up together). This is very similar to the form used by OpenOffice. (those of you who have OpenOffice, just change the “.sxw” extension to “.zip” on one of your files and then open it to see what I mean).
More coverage at:
http://www.washingtonpost.com/wp-dyn/conte…5060101974.html%5B/url%5D -
WSAndrew77
AskWoody LoungerI’ve never used VBA with Access (I’ve barely used Access), but in Word you can do something like this with the Calendar Control:
Private Sub UserForm_Activate() Me.Calendar1.Value = DateAdd("m", 6, Date) End Sub
-
WSAndrew77
AskWoody LoungerTry this on for size:
Function PopOuterTable2(tbl As Table) As Boolean Dim t As Table For Each t In tbl.Parent.Tables If tbl.Range.InRange(t.Range) And tbl.NestingLevel > 1 Then t.ConvertToText wdSeparateByParagraphs, False PopOuterTable2 = True Exit Function End If Next t PopOuterTable2 = False End Function
Only top-level tables are included in the document’s Tables collection.
-
WSAndrew77
AskWoody LoungerTry System.PrivateProfileString:
Sub ReadReg() MsgBox System.PrivateProfileString("", _ "HKEY_CURRENT_USERSoftwareGoogleGmailFlags", _ "browser") ' --> "firefox.exe" End Sub
If you leave the FileName argument blank, VBA looks in the Registry.
-
WSAndrew77
AskWoody LoungerIf by “limit user’s visibility”, you mean that you don’t want the procedures to appear in the Macros dialog (Tools->Macro->Macros), you can assign an unused optional parameter:
Visible from Macros dialog:
Sub HelloWorld() MsgBox "Hello, World!" End Sub
Not visible:
Sub HelloWorld(Optional bNull as Boolean) MsgBox "Hello World" End Sub
Both can be called identically from other procedures, ie:
Call HelloWorld
-
WSAndrew77
AskWoody LoungerUsing the full first sentence is how Word 2003 works for me (at least on the two machines I use regularly). The filename you’re saying that Word is using is exactly 8 characters long, which suggests that either Word or Windows is trying to force you to use the old 8.3 filename (8 characters plus 3-character extension) standard.
-
WSAndrew77
AskWoody LoungerI would say it’s almost certainly the touchpad. That happens to me with almost any laptop I use.
Most laptops have a means of disabling the touchpad, either via a button directly above it, or, more commonly, a Function Key combo (mine’s Fn-F4). Look for an F key (F1-F12) with a picture of a mouse or a mouse with an X through it, or something like that. Fn plus that key should disable the touchpad (pressing it again will toggle it back on).
-
WSAndrew77
AskWoody LoungerThere are some subtle parts of this problem that unfortunately I don’t have time to explore right now, but perhaps this will help you or another lounger get to a useful solution.
The following macro (which uses three supporting functions) makes a list of random numbers between 1 and the number of sentences in the document. Then a new document is created, and the sentences from the original are copied over in that random order.
The subtleties I was talking about:
1. Word’s definition of a “sentence” is not always the same as yours.
2. The trailing paragraph mark at the end of the last sentence in a paragraph is considered part of that sentence, so your paragraph breaks get a bit scrambled.
3. I know not enough about randomization to know if this is truly “random” enough for your purposes.At any rate, it’s an intriguing litte puzzle, and I hope I’ve put the first few pieces in place.
Sub ShuffleSentencesInDoc() Dim doc As Document Dim docShuffled As Document Dim lRandNum As Long Dim k As Long Dim lSentenceCount As Long Dim vRand() As Variant ReDim vRand(0) Set doc = ActiveDocument lSentenceCount = doc.Sentences.count Do While UBound(vRand) < doc.Sentences.count lRandNum = GenerateBoundedRandomNumber(1, lSentenceCount) If Not IsMember(vRand, lRandNum) Then Push vRand, lRandNum End If Loop Set docShuffled = Documents.Add For k = 1 To lSentenceCount docShuffled.Range.InsertAfter doc.Sentences(vRand(k)).Text Next k End Sub Function GenerateBoundedRandomNumber(lLbound As Long, lUbound As Long) As Long Randomize GenerateBoundedRandomNumber = Int((lUbound - lLbound + 1) * Rnd + lLbound) End Function Function Push(ByRef vArray As Variant, ByVal vItem As Variant) ReDim Preserve vArray(UBound(vArray) + 1) vArray(UBound(vArray)) = vItem End Function Function IsMember(vArray As Variant, ByVal vItem As Variant) Dim v As Variant For Each v In vArray If v = vItem Then IsMember = True Exit Function End If Next v IsMember = False End Function
-
WSAndrew77
AskWoody LoungerActiveDocument.Undo
There’s an optional “Times” argument, as well.
-
WSAndrew77
AskWoody LoungerSorry about that. Leave off the 0 in the variant array declarations. I’ve edited the previous post to reflect the change.
![]() |
Patch reliability is unclear. Unless you have an immediate, pressing need to install a specific patch, don't do it. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |

Plus Membership
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Get Plus!
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Search Newsletters
Search Forums
View the Forum
Search for Topics
Recent Topics
-
The April 2025 Windows RE update might show as unsuccessful in Windows Update
by
Susan Bradley
1 minute ago -
Firefox 137
by
Charlie
2 hours, 44 minutes ago -
Whisky, a popular Wine frontend for Mac gamers, is no more
by
Alex5723
6 hours, 12 minutes ago -
Windows 11 Insider Preview build 26120.3863 (24H2) released to BETA
by
joep517
6 hours, 25 minutes ago -
Windows 11 Insider Preview build 26200.5551 released to DEV
by
joep517
6 hours, 27 minutes ago -
New Windows 11 PC setup — can I start over in the middle to set up a local id?
by
ctRanger
2 hours, 27 minutes ago -
Windows 11 Insider Preview Build 26100.3902 (24H2) released to Release Preview
by
joep517
9 hours, 59 minutes ago -
Oracle kinda-sorta tells customers it was pwned
by
Nibbled To Death By Ducks
16 hours ago -
Global data centers (AI) are driving a big increase in electricity demand
by
Kathy Stevens
1 day, 2 hours ago -
Office apps read-only for family members
by
b
1 day, 4 hours ago -
Defunct domain for Microsoft account
by
CWBillow
1 day, 1 hour ago -
24H2??
by
CWBillow
16 hours ago -
W11 23H2 April Updates threw ‘class not registered’
by
WindowsPersister
10 hours, 14 minutes ago -
Master patch listing for April 8th, 2025
by
Susan Bradley
10 hours, 27 minutes ago -
TotalAV safety warning popup
by
Theodore Nicholson
1 hour, 15 minutes ago -
two pages side by side land scape
by
marc
3 days, 2 hours ago -
Deleting obsolete OneNote notebooks
by
afillat
3 days, 4 hours ago -
Word/Outlook 2024 vs Dragon Professional 16
by
Kathy Stevens
2 days, 7 hours ago -
Security Essentials or Defender?
by
MalcolmP
2 days, 10 hours ago -
April 2025 updates out
by
Susan Bradley
5 hours, 29 minutes ago -
Framework to stop selling some PCs in the US due to new tariffs
by
Alex5723
2 days, 3 hours ago -
WARNING about Nvidia driver version 572.83 and 4000/5000 series cards
by
Bob99
1 day, 17 hours ago -
Creating an Index in Word 365
by
CWBillow
2 days, 20 hours ago -
Coming at Word 365 and Table of Contents
by
CWBillow
1 day, 8 hours ago -
Windows 11 Insider Preview Build 22635.5170 (23H2) released to BETA
by
joep517
3 days, 23 hours ago -
Has the Microsoft Account Sharing Problem Been Fixed?
by
jknauth
4 days, 3 hours ago -
W11 24H2 – Susan Bradley
by
G Pickerell
4 days, 5 hours ago -
7 tips to get the most out of Windows 11
by
Alex5723
4 days, 3 hours ago -
Using Office apps with non-Microsoft cloud services
by
Peter Deegan
4 hours, 52 minutes ago -
I installed Windows 11 24H2
by
Will Fastie
2 days, 2 hours ago
Recent blog posts
Key Links
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.