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, 2 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
-
Login screen icon
by
CWBillow
4 hours, 34 minutes ago -
AI coming to everything
by
Susan Bradley
41 minutes ago -
Mozilla : Pocket shuts down July 8, 2025, Fakespot shuts down on July 1, 2025
by
Alex5723
12 hours, 2 minutes ago -
No Screen TurnOff???
by
CWBillow
12 hours, 23 minutes ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
12 hours, 56 minutes ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
1 day ago -
How well does your browser block trackers?
by
n0ads
10 hours, 50 minutes ago -
You can’t handle me
by
Susan Bradley
3 hours, 18 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
3 hours, 27 minutes ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
1 day, 11 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
15 hours, 25 minutes ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
1 day, 12 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
1 day, 12 hours ago -
Lumma malware takedown
by
EyesOnWindows
1 day ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
1 day, 21 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
1 day, 21 hours ago -
Meet Gemini in Chrome
by
Alex5723
2 days, 1 hour ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
2 days, 1 hour ago -
Trump signs Take It Down Act
by
Alex5723
2 days, 9 hours ago -
Do you have a maintenance window?
by
Susan Bradley
13 hours, 59 minutes ago -
Freshly discovered bug in OpenPGP.js undermines whole point of encrypted comms
by
Nibbled To Death By Ducks
1 day, 11 hours ago -
Cox Communications and Charter Communications to merge
by
not so anon
2 days, 12 hours ago -
Help with WD usb driver on Windows 11
by
Tex265
4 hours, 45 minutes ago -
hibernate activation
by
e_belmont
2 days, 21 hours ago -
Red Hat Enterprise Linux 10 with AI assistant
by
Alex5723
3 days, 1 hour ago -
Windows 11 Insider Preview build 26200.5603 released to DEV
by
joep517
3 days, 4 hours ago -
Windows 11 Insider Preview build 26120.4151 (24H2) released to BETA
by
joep517
3 days, 4 hours ago -
Fixing Windows 24H2 failed KB5058411 install
by
Alex5723
2 days ago -
Out of band for Windows 10
by
Susan Bradley
3 days, 9 hours ago -
Giving UniGetUi a test run.
by
RetiredGeek
3 days, 16 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.