I have a word doc with various form fields inserted. On one field, there is a list of values for a drop-down and in another field, there is a Number associated with each program name. What I’d like to do is have the Program Number field automatically update itself depending on the selection of the Program Name field. I have created a Select Case macro but haven’t had much success referencing the Program Name Field value to set the variable for the Select Case code. How do you reference the value of a Word field (or, as it calls itself, a Bookmark) in code?
![]() |
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 |
-
Referencing a Bookmark (field) in Macro (Win 2KPro, Office2KPro)
Home » Forums » AskWoody support » Productivity software by function » MS Word and word processing help » Referencing a Bookmark (field) in Macro (Win 2KPro, Office2KPro)
- This topic has 9 replies, 5 voices, and was last updated 22 years ago.
AuthorTopicWSsteve_skelton13
AskWoody LoungerMay 21, 2003 at 1:56 pm #387865Viewing 1 reply threadAuthorReplies-
WScarbonnb
AskWoody Lounger -
WSDoryO
AskWoody LoungerMay 21, 2003 at 3:46 pm #678598Here’s an idea. Use the “Run macro on Exit” property of the first drop-down field to update the second field:
Sub DropDown1_Exit() Select Case ActiveDocument.FormFields("Dropdown1").Result Case "Peter" n = 10 Case "Paul" n = 20 Case "Mary" n = "30" End Select ActiveDocument.FormFields("Dropdown2").Result = n End Sub
Unfortunately, the user has to actually EXIT the field before the updating occurs.
In a real UserForm (not a form field in a doc) you could make this update “real-time” which users will find more intuitive. -
WSsteve_skelton13
AskWoody LoungerMay 21, 2003 at 3:55 pm #678606that looks about right. from what i can gather, Word Form fields apply macros either on Exit or on Enter & applying the change to On Exit for the Program Names field (which will be tabbed in before Program Number) is the better choice. Of course, even better would be to not have an ‘updateable’ Program Number field because, after going thru all the trouble to assign a value to it, the User could tab in, erase or change the assigned value…in which case you’d have to re-run the same macros as on on Exit to Program Number field. A little goofy, but I wouldn’t be suprised if Word’s form field handling is primitive. There’s no radio buttons provided in the Forms toolbar, for instance. Also, not sure if you can control tab order or disable a field. Well, it ain’t Access we’re talking about, but Word. I’ve asked my client to look over the automation & let me know if drop-downs are even something he wants. With the drop-downs, you prevent multiple selections for a category, but the form no longer looks like the passive paper form so it may be more confusing for the user. don’t know…I *like* drop-downs, but that doesn’t mean the client will!
-
WSDoryO
AskWoody LoungerMay 21, 2003 at 7:14 pm #678618(Edited by HansV to activate link to post – see Help 19)
Good points, Steve. I just posted a summary of how I like to do “form fill-in” templates in another thread: post 255721
I insert a UserForm in the VB editor and use it to allow proper data entry with all the bells & whistles then stuff the results in fields & bookmarks, etc.
Form Fields just don’t cut it after you’ve used real forms. UserForms are practically the same thing you’re used to in MS Access forms. -
WSsteve_skelton13
AskWoody LoungerMay 21, 2003 at 5:30 pm #678630Thanks for the reply, esp. the referenced thread discussion. I might need to use {REF} in some fields as info is repeated on the second page of the form. As for using VB to create better forms in Word, good suggestion but for this project I think I can get by using what Word makes available.
One thing that is actually something of a positive using Word’s native form toolset: you get a very good sense of how the form would look in HTML/asp! The native form handling with these technologies is even more primitive, as you don’t have onExit events. For example, you can select a Program Name in the initial form and have the system find/display the associated Program Number on the preview/submit page. (You could probably use javascript for event-driven web pages, but I avoid javascript for critical functionality as there are browser compatibility issues with javascript.) But you can see how a web page might look after creating a form in Word (except of course Radio Buttons, which don’t exist in Word forms but do in HTML).
-
WSAlanMiller
AskWoody Lounger -
WSDoryO
AskWoody LoungerMay 24, 2003 at 10:11 pm #679547Right you are, Alan. In Word’s Tools…Macros… menu, it is called the “Visual Basic Editor”. I wouldn’t send anyone over to Visual Basic 6.0 for a simple trick like this!
When you know how to do little tricks in the “VB Editor” of Word, Excel & Access you hardly ever have to bother with Visual Basic stand-alone application development. I hope more people try Visual Basic for Applications (or macros or embedded VB or whatever you want to call it) and aren’t scared off by the idea of “programming”. It’s great stuff. (The night security guard at my client’s office was reading a C++ manual the other night. Lookin’ for a career change. I recommended he start with VBA macros in Excel or Word before tackling that challenge. Got to have some easy wins to keep scaling that learning curve.) OK…this is getting WAY off topic. Apology to moderator.
-
WSsteve_skelton13
AskWoody LoungerMay 27, 2003 at 5:23 pm #680103that’s what i assumed when she suggested using VB for creating custom forms. I’ve never actually tried using VB 6+ etc. but have done a lot of stuff using VB for Office in various apps. However, when I stated I’d stick with the native form elements provided by Word, I was referring to what you get in the View | Toolbars… Forms toolbar. You have to use the VB Editor in Word to hook up actions on these Word forms (which seem to be a collection of custom field codes) at any rate.
-
-
-
-
WSsteve_s@home
AskWoody Lounger
-
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
-
Woody (Awaiting moderation)
by
Scott
1 hour, 21 minutes ago -
24H2 has suppressed my favoured spider
by
Davidhs
3 hours, 39 minutes ago -
GeForce RTX 5060 in certain motherboards could experience blank screens
by
Alex5723
11 hours, 35 minutes ago -
MS Office 365 Home on MAC
by
MickIver
5 hours, 24 minutes ago -
Google’s Veo3 video generator. Before you ask: yes, everything is AI here
by
Alex5723
1 day, 1 hour ago -
Flash Drive Eject Error for Still In Use
by
J9438
1 day, 3 hours ago -
Windows 11 Insider Preview build 27863 released to Canary
by
joep517
1 day, 20 hours ago -
Windows 11 Insider Preview build 26120.4161 (24H2) released to BETA
by
joep517
1 day, 20 hours ago -
AI model turns to blackmail when engineers try to take it offline
by
Cybertooth
1 day ago -
Migrate off MS365 to Apple Products
by
dmt_3904
1 day ago -
Login screen icon
by
CWBillow
15 hours, 21 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
2 days, 12 hours ago -
No Screen TurnOff???
by
CWBillow
2 days, 12 hours ago -
Identify a dynamic range to then be used in another formula
by
BigDaddy07
2 days, 13 hours ago -
InfoStealer Malware Data Breach Exposed 184 Million Logins and Passwords
by
Alex5723
3 days ago -
How well does your browser block trackers?
by
n0ads
2 days, 10 hours ago -
You can’t handle me
by
Susan Bradley
9 hours, 45 minutes ago -
Chrome Can Now Change Your Weak Passwords for You
by
Alex5723
2 days, 3 hours ago -
Microsoft: Over 394,000 Windows PCs infected by Lumma malware, affects Chrome..
by
Alex5723
3 days, 12 hours ago -
Signal vs Microsoft’s Recall ; By Default, Signal Doesn’t Recall
by
Alex5723
2 days, 15 hours ago -
Internet Archive : This is where all of The Internet is stored
by
Alex5723
3 days, 12 hours ago -
iPhone 7 Plus and the iPhone 8 on Vantage list
by
Alex5723
3 days, 12 hours ago -
Lumma malware takedown
by
EyesOnWindows
3 days ago -
“kill switches” found in Chinese made power inverters
by
Alex5723
3 days, 21 hours ago -
Windows 11 – InControl vs pausing Windows updates
by
Kathy Stevens
3 days, 21 hours ago -
Meet Gemini in Chrome
by
Alex5723
4 days, 1 hour ago -
DuckDuckGo’s Duck.ai added GPT-4o mini
by
Alex5723
4 days, 1 hour ago -
Trump signs Take It Down Act
by
Alex5723
4 days, 9 hours ago -
Do you have a maintenance window?
by
Susan Bradley
2 days, 14 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.