OK folks, here’s my problem: I have a UserForm with a multiselect listbox that checks items according to whether the font.hidden property is true (-1) or false (0) for certain bookmarks in the document. I’m getting funny behaviour – for some bookmarks, the code is returning neither -1 nor 0, but 9999999. I’m sure I’ve read about something like this with some other attribute somewhere. I’m (pretty) sure the range within the bookmark won’t ever be mixed “some hidden & some not”, so what’s going on here? If I try to check for 9999999 and set it to -1 when it’s found, will that work?
The range within each bookmark is some rows of a table, if this helps (code does seem to work fine on plain ol’ paragraph text); oh, and the first cell in each row is formatted with a style that has outline numbering, too.
![]() |
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 |
-
font.hidden property, tables and code (2000)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » font.hidden property, tables and code (2000)
- This topic has 8 replies, 4 voices, and was last updated 21 years, 10 months ago.
AuthorTopicWSDaveW
AskWoody LoungerJuly 4, 2003 at 7:27 am #390022Viewing 0 reply threadsAuthorReplies-
WSHansV
AskWoody LoungerJuly 4, 2003 at 8:03 am #691142Word is not able to determine many formatting properties of a range if that range contains 50 paragraphs or more, so it returns wdUndefined (9999999). This return value only implies that the range contains a mixture of settings if the range is small enough; for large ranges you can’t draw any conclusion from the return value wdUndefined.
So my guess is that “some rows of a table” contain 50 paragraphs or more.
-
WSDaveW
AskWoody LoungerJuly 4, 2003 at 8:41 am #691148Aha; thanks HansV, I didn’t know that.
Yes, I’ve checked the paragraphs.count for each of the bookmarked ranges in the table, and – you’re right – the ones that give trouble have 70 paragraphs in them.
So perhaps what I need to do is *not* have a bookmark that encompasses the whole range to be considered, but one that marks the start, another that marks the end, and have the code just ask about the .hidden property of the starting bookmark, then work with a range that’s defined as eveything between the two?
Heck: thinking as I type, since the first row of each range (and only the first – so at maximum 3 paragraphs, one for each cell in that row) is formatted with a specific style, maybe I should find some way to scrap the bookmarks altogether and identify the ranges according to style, and determine the .hidden property as it’s applied to each occurrence of that style. Hmm… -
WSjscher2000
AskWoody Lounger -
WSDaveW
AskWoody LoungerJuly 7, 2003 at 7:03 am #691642Yes; thanks to you both for these inputs. I think I’ve got a working solution now: I’ve added a second column to the listbox, and put in it the row number where the specified style occurs. So if the style is on rows 1, 12, and 22 (for example) the listbox has items:
blah blah blah | 1
more blah blah | 12
yet more blah | 22. (etc.)
…Then according to whether the item is checked or not I can set rows 1-11, 12-21 or 22-.count as hidden or not hidden.
Because I’m looking at the styles now, this will still work if users add their own “sections” to the table (which it didn’t when I was relying on bookmarks). -
WSDaveW
AskWoody LoungerJuly 16, 2003 at 9:47 pm #694024(Edited by jscher2000 on 16-Jul-03 15:47.
and
markup added around code snippet to preserve indenting.)
Hi guys:
Though the code for applying/retrieving the hidden property is now sorted, after a couple of days not working with the document I’ve now gone back in and found that populating the listbox in the first place is running unbelievably slowly.
Here’s an idea of the structure of the table, then I’ll show the code I’ve got populating the listbox: can anybody see how I might make it run *way* faster?
Table has 3 columns. All the text in cols 2 and 3 is formatted with a style called “response”. In the first column, some rows have text in “Matrix 1” style (these are ‘section headings’ within the table), others have text in “Matrix 2” style (these are items under the headings). Matrix 1 and Matrix 2 styles are outline numbered (1, 2, 3 for Matrix 1; 1.1, 1.2 etc for Matrix 2).
First part of the code for populating the listbox (slow running part):Dim iRow As Row, i As Integer, j As Integer, aRange As Range i = 1 j = 1 With ActiveDocument.Tables(1) For Each iRow In .Rows Set aRange = iRow.Cells(1).Range aRange.TextRetrievalMode.IncludeHiddenText = True If aRange.Paragraphs(1).Style = "matrix h1" Then LstSections.AddItem Left(aRange.Paragraphs(1).Range.Text, _ Len(aRange.Paragraphs(1).Range.Text) - 2) LstSections.List(j - 1, 1) = i j = j + 1 End If i = i + 1 Next iRow '(more code to SELECT items in the list if the corresponding part ' of the table is not formatted as hidden text, then: ) End With
(Note: I’m chopping off the last two characters in each range because it’s in table cells and I don’t want the para mark or cell division character, etc.)
-
WSHansV
AskWoody LoungerJuly 16, 2003 at 4:15 pm #694096I don’t have specific recommendations, but perhaps you can profit from the tips in Maximising the performance of Word tables on the Word MVP site. The second part is about handling tables in code.
According to this article, the fastest way to process the cells of a table is to select the table and loop through its cells:
Dim oCell As Cell
ActiveDocument.Tables(1).Select
For Each oCell In Selection.Cells
…
Next oCell -
WSDaveW
AskWoody LoungerJuly 17, 2003 at 7:25 am #694272Thanks HansV, I’ve printed off Dave Rado’s article (I’ve found his articles to be v. useful in the past), and it looks like there’s stuff I can play with here that should increase speed. There’s certainly a suggestion that if I select a cell in column 1, then select the column, and work with the cells in the selection, that should be faster. I’ll try some of these things out and post an update when I see what happens!
(Unfortunately the best time for me to concentrate on this sort of stuff is on my machine at home – when *anything* runs pretty fast… but then I have to bring it all back in to work, whereupon I find out what’s genuinely fast and what isn’t!!) -
WSKlaus Linke
AskWoody LoungerJuly 17, 2003 at 3:14 pm #694458Don’t know if it is in Dave Rado’s article, but you can get the whole text from a table into a string in one fell swoop:
myString=ActiveDocument.Tables(1).Range.TextYou’d have end-of-cell-markers Chr(13)&Chr(7) after each cell, and additional ones at the end of each row.
If your table is uniform (no merged/split cells), you can easily retrieve the contents of the cells (for example by splitting the string up with Split).
Klaus
-
-
-
-
Viewing 0 reply threads -

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
-
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
6 minutes ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
7 minutes ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
3 hours, 17 minutes ago -
Out of band for Windows 10
by
Susan Bradley
4 hours, 50 minutes ago -
Giving UniGetUi a test run.
by
RetiredGeek
11 hours, 48 minutes ago -
Windows 11 Insider Preview Build 26100.4188 (24H2) released to Release Preview
by
joep517
19 hours, 25 minutes ago -
Microsoft is now putting quantum encryption in Windows builds
by
Alex5723
17 hours, 23 minutes ago -
Auto Time Zone Adjustment
by
wadeer
23 hours, 54 minutes ago -
To download Win 11 Pro 23H2 ISO.
by
Eddieloh
21 hours, 34 minutes ago -
Manage your browsing experience with Edge
by
Mary Branscombe
2 hours, 9 minutes ago -
Fewer vulnerabilities, larger updates
by
Susan Bradley
13 hours, 5 minutes ago -
Hobbies — There’s free software for that!
by
Deanna McElveen
17 hours, 23 minutes ago -
Apps included with macOS
by
Will Fastie
17 hours ago -
Xfinity home internet
by
MrJimPhelps
16 hours, 56 minutes ago -
Convert PowerPoint presentation to Impress
by
RetiredGeek
16 hours, 53 minutes ago -
Debian 12.11 released
by
Alex5723
1 day, 21 hours ago -
Microsoft: Troubleshoot problems updating Windows
by
Alex5723
2 days ago -
Woman Files for Divorce After ChatGPT “Reads” Husband’s Coffee Cup
by
Alex5723
1 day, 4 hours ago -
Moving fwd, Win 11 Pro,, which is best? Lenovo refurb
by
Deo
20 hours, 35 minutes ago -
DBOS Advanced Network Analysis
by
Kathy Stevens
2 days, 17 hours ago -
Microsoft Edge Launching Automatically?
by
healeyinpa
2 days, 8 hours ago -
Google Chrome to block admin-level browser launches for better security
by
Alex5723
5 hours, 46 minutes ago -
iPhone SE2 Stolen Device Protection
by
Rick Corbett
2 days, 12 hours ago -
Some advice for managing my wireless internet gateway
by
LHiggins
1 day, 20 hours ago -
NO POWER IN KEYBOARD OR MOUSE
by
HE48AEEXX77WEN4Edbtm
22 hours, 5 minutes ago -
A CVE-MITRE-CISA-CNA Extravaganza
by
Nibbled To Death By Ducks
3 days, 5 hours ago -
Sometimes I wonder about these bots
by
Susan Bradley
17 hours, 55 minutes ago -
Does windows update component store “self heal”?
by
Mike Cross
2 days, 16 hours ago -
Windows 11 Insider Preview build 27858 released to Canary
by
joep517
3 days, 19 hours ago -
Pwn2Own Berlin 2025: Day One Results
by
Alex5723
2 days, 3 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.