|
Quickly change your view of field shading in Word between Always, Never, and When selected using VBA.
Run code or assign keyboard shortcuts to trigger your macros.
Download zipped BAS file you can import into your VBA projects: mod_Word_FieldShading_s4p__BAS.zip
Remember to UNBLOCK files you download to remove the Mark of the Web. Here are steps to do that: https://msaccessgurus.com/MOTW_Unblock.htm
If this code is in your Normal template, you can call it from anywhere
'*************** Code Start ***************************************************** ' module name: mod_Word_FieldShading_s4p '------------------------------------------------------------------------------- ' Purpose : change field shading of ActiveWindow view in Word ' Author : crystal (strive4peace) ' Code List: https://msaccessgurus.com/code.htm ' This code: https://msaccessgurus.com/VBA/Word_FieldShading.htm ' LICENSE : ' You may freely use and share this code, but not sell it. ' Keep attribution. Use at your own risk. '------------------------------------------------------------------------------- ' wdFieldShadingNever = 0 ' wdFieldShadingAlways = 1 ' wdFieldShadingWhenSelected = 2 '------------------------------------------------------------------------------- ' aFieldShading_ALWAYS '------------------------------------------------------------------------------- Public Sub aFieldShading_ALWAYS() '230321 strive4peace ActiveDocument.ActiveWindow.View.FieldShading = 1 End Sub '------------------------------------------------------------------------------- ' aFieldShading_SELECTED '------------------------------------------------------------------------------- Public Sub aFieldShading_SELECTED() '230321 strive4peace ActiveDocument.ActiveWindow.View.FieldShading = 2 End Sub '------------------------------------------------------------------------------- ' aFieldShading_NO '------------------------------------------------------------------------------- Public Sub aFieldShading_NO() '230321 strive4peace ActiveDocument.ActiveWindow.View.FieldShading = 0 End Sub '*************** Code End *******************************************************' Code was generated with colors using the free Color Code add-in for Access.
To change how fields are displayed using the Word Options:
You can assign shortcut keys to public Subs.
View.FieldShading property (Word)
With the view object, you can set other properties such as zoom, bookmarks, comments, field codes, and a lot more.
When you're working with fields in Word, it's several clicks to go back and forth between the display choices using Word's options.
This code is easy to add to your Normal template so you can use it for any document. Press Alt-F8 for a list of macros and choose what you want to run. I generally begin the name the procedures I'll call a lot with a little 'a' so they sort at the top of the list.
If you want to make it even quicker, assign shortcut keys.
If you like this page, please let me know. Donations, even small ones, help, thank you
Here's the link for this page in case you want to copy it and share it with someone:
https://msaccessgurus.com/VBA/Word_FieldShading.htm
or in old browsers:
http://www.msaccessgurus.com/VBA/Word_FieldShading.htm
Let's connect and team-develop your application together. I teach you how to do it yourself. My goal is to empower you.
While we build something great together, I'll pull in code and features from my vast libraries as needed, cutting out lots of development time. I'll give you lots of links to good resources.
Lots of times, your data is stored in Access,
and Word is fantastic at formattting!
Do you want your take better advantage of Word?
I'd love to help you.
Email me at training@msAccessGurus
~ crystal
the simplest way is best, but usually the hardest to see