Our group of 4 will be working on docs with lots of tables. Our table border & heading row shading need RGB values entered, so I’ve recorded a macro to do this. Trouble is some tables have more heading rows than others. How do you stop the macro till the user selects the rows that need shading, then continue the macro after they’ve made their selection? I could do two separate macros, one for the borders, then another for the shading, but I’d like to wrap it all into one if I can.
![]() |
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 |
-
macro problem (2003, SP2)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » macro problem (2003, SP2)
- This topic has 13 replies, 4 voices, and was last updated 17 years, 3 months ago.
AuthorTopicWSNancy-Potter
AskWoody LoungerMarch 1, 2008 at 1:00 am #449067Viewing 1 reply threadAuthorReplies-
WSHansV
AskWoody LoungerMarch 1, 2008 at 1:21 am #1099962A macro can’t pause to let the user select something.
You could let the user select the heading rows before running the macro, then format first the heading rows and next the rest of the table.
Or you could prompt the user to enter the number of heading rows (using the InputBox function), and use that in your macro.Another option would be to create two macros, and at the end of the first macro display a message box that tells the user that he/she has 20 seconds to select the heading rows, then run the second macro with a 20 second delay:
Application.OnTime Now + TimeSerial(0, 0, 20), “OtherMacro”
But I don’t think that is a good strategy – the time might be too short for some users and too long for others, and if the user starts doing something else in the interval, results would be unpredictable.
-
WSNancy-Potter
AskWoody Lounger
-
WSjscher2000
AskWoody LoungerMarch 1, 2008 at 2:25 am #1099965-
WSNancy-Potter
AskWoody Lounger -
WSjscher2000
AskWoody Lounger -
WSNancy-Potter
AskWoody LoungerMarch 4, 2008 at 1:44 am #1100374Both suggestions here are great ideas, but I’m such a novice at code that I can’t figure out how to get either into my macro & have it work; I’ve tried lots of different ways and nothing works. I am taking a one-day overview on VBA for Word next month; maybe I’ll “get it” after I do that. I’m keeping a copy of both attachments so I’ll be able to try it again later.
my attachment has the macros for table borders & shading that I recorded and a 4-second break between the two. I know I’ve got loads of nerve for asking, but if anyone has the time, can you show me how to hook it all up? Thanks.
-
WSHansV
AskWoody LoungerMarch 4, 2008 at 1:58 am #1100377In the attached version of your document, I have added a userform along st3333ve’s ideas.
When you run your macro VB_borders, it opens the form at the end. You can then select the header rows, and click OK when you’re ready to continue. The OK button simply calls your second macro and closes the form. -
WSjscher2000
AskWoody LoungerMarch 4, 2008 at 1:58 am #1100378Mine was set up as a separate sub you can call to have the user extend the selection. This would run in “real time” and you would not use the timer method.
To get all the pieces into your template: Open my document and press Alt+F11 to launch the VBE. In the Project Explorer, right-click and and export both the modTHRS code module and the frmTHRS form module to a convenient folder. Then switch to any code pane in your template and import those two modules into your template.
In your code, you can call my procedure, passing in the table, in the same manner as the TEST_TableHeaderRowSelect() procedure calls it. Does that make sense?
-
byteme
AskWoody PlusMarch 4, 2008 at 6:59 am #1100401If you’d prefer to have the box pop up in the upper right corner (more out of the way) with the focus back on the table, you could make the following 2 tweaks to the HansV version:
1. In the properties for frmSelect (which you adjust in the Properties Window in the VBEditor: View –> Properties Window), you’d change StartUpPosition to Manual.
2. At the end of VX_borders, you’d substitute the following for the frmSelect.Show line:
Dim frm As frmSelect
Set frm = New frmSelect
With frm
.Left = ActiveWindow.Width – 200
.Top = 60
.Show
End With
AppActivate ActiveDocument.Name
Set frm = Nothing -
WSNancy-Potter
AskWoody Lounger -
byteme
AskWoody PlusMarch 5, 2008 at 7:15 am #1100605He’s ba-a-a-a-a-a-ck.
“Is this your FINAL version, st3333ve?”
“Um, I think so.”
In the attached version, I’ve separated out the pause-and-prompt process as a separate, generic PausePrompt procedure that you can use with any pair of macros (without creating a separate form) where you want to run the first macro, then pause (with a user prompt), then run the 2nd macro.
As shown in the attachment, you call the PausePrompt procedure at the end of the first macro, and PausePrompt takes 4 arguments:
1. The prompt.
2. The name of the 2nd macro.
3. (optional) The title shown at the top of the UserForm. (The default is “Macro is paused …”)
4. (optional) The button caption. (The default is “Continue”.)The attached document includes your macro pair (run VX_borders) and a 2nd demo pair (run TestPausePrompt).
For anyone with a similar interest in this kind of multi-use form, I note that it takes advantage of the ability of UserForm labels to automatically size themselves to fit the caption (assuming you set the AutoSize property to True). (Adjusting the other form elements to accommodate the expanded label takes a little more effort, alas.)
-
-
-
-
byteme
AskWoody PlusMarch 1, 2008 at 8:22 am #1099979I’m somewhat of a duffer and inexperienced at providing Attachments, so my apologies if this doesn’t work (this round, anyway), but attached (or so I hope) is a Word document with an alternative, more generic approach that can allow for (effectively) the kind of “pauses” in macros that WordPerfect macro writers are used to.
When you run my TestReddenRows macro, it calls up a modeless UserForm (the start of the “pause”) that prompts the user. Because the UserForm is modeless, the user can do things with the document while the UserForm remains onscreen (and the AppActivate line initially shifts the focus away from the UserForm and onto the document).
To terminate the pause, the user clicks the button on the UserForm, and you put any post-“pause” processing in the button’s click event (in the code behind the UserForm). (In my example, the post-pause processing just colors the selection red.)
-
byteme
AskWoody PlusMarch 1, 2008 at 7:23 pm #1100034
Viewing 1 reply thread -

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
-
Migrating from win10 to win11, instructions coming?
by
astro46
4 hours, 42 minutes ago -
Device Eligibility for Apple 2026 Operating Systems due this Fall
by
PKCano
6 hours, 12 minutes ago -
Recommended watching : Mountainhead movie
by
Alex5723
10 hours, 37 minutes ago -
End of support for Windows 10
by
Old enough to know better
7 hours, 56 minutes ago -
What goes on inside an LLM
by
Michael Covington
2 hours, 36 minutes ago -
The risk of remote access
by
Susan Bradley
42 minutes ago -
The cruelest month for many Office users
by
Peter Deegan
7 hours, 16 minutes ago -
Tracking protection and trade-offs in Edge
by
Mary Branscombe
12 hours, 51 minutes ago -
Supreme Court grants DOGE access to confidential Social Security records
by
Alex5723
19 hours, 28 minutes ago -
EaseUS Partition Master free 19.6
by
Alex5723
6 hours, 38 minutes ago -
Microsoft : Edge is better than Chrome
by
Alex5723
1 day, 8 hours ago -
The EU launched DNS4EU
by
Alex5723
1 day, 21 hours ago -
Cell Phone vs. Traditional Touchtone Phone over POTS
by
280park
1 day, 11 hours ago -
Lost access to all my networked drives (shares) listed in My Computer
by
lwerman
2 days, 2 hours ago -
Set default size for pasted photo to word
by
Cyn
2 days, 8 hours ago -
Dedoimedo tries 24H2…
by
Cybertooth
1 day, 21 hours ago -
Windows 11 Insider Preview build 27871 released to Canary
by
joep517
3 days, 7 hours ago -
Windows 11 ad from Campaign Manager in Windows 10
by
Jim McKenna
1 day ago -
Small desktops
by
Susan Bradley
1 hour, 24 minutes ago -
Totally disable Bitlocker
by
CWBillow
2 days, 1 hour ago -
Phishers extract Millions from HMRC accounts..
by
Microfix
3 days, 5 hours ago -
Windows 10 22H2 Update today (5 June) says up-to-date but last was 2025-04
by
Alan_uk
4 days, 11 hours ago -
Thoughts on Malwarebytes Scam Guard for Mobile?
by
opti1
2 days, 6 hours ago -
Mystical Desktop
by
CWBillow
4 days, 15 hours ago -
Meta and Yandex secretly tracked billions of Android users
by
Alex5723
3 days, 20 hours ago -
MS-DEFCON 2: Do you need that update?
by
Susan Bradley
1 day, 7 hours ago -
CD/DVD drive is no longer recognized
by
WSCape Sand
5 days, 6 hours ago -
Windows 11 24H2 Default Apps stuck on Edge and Adobe Photoshop
by
MikeBravo
5 days, 9 hours ago -
North Face and Cartier customer data stolen in cyber attacks
by
Alex5723
5 days, 7 hours ago -
What is wrong with simple approach?
by
WSSpoke36
3 days, 5 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.