small image of Word field shading Ms Access Gurus

Do you like this? Help support MsAccessGurus

Word Field Shading

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.

quickly change field shading using macros or keyboard shortcuts in Word

Quick Jump

Goto Top  


Download

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

Goto Top  

VBA

Standard module

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.

Goto Top  

Steps to set Field Shading in Word Options

To change how fields are displayed using the Word Options:

  1. Go to Word Options
  2. Choose Advanced
  3. Scroll to the Show document content section
  4. Choose what you want in the list for Field shading

    choices for Word field shading
  5. Click OK

Goto Top  

Assign Shortcut Keys

You can assign shortcut keys to public Subs.

  1. Go to Word Options
  2. Choose Customize Ribbon (not an intuitive thing to choose to customize the keyboard ... but this is where it is)
  3. Click the Customize... button next to Keyboard shortcuts in the lower left or press Alt-t


    click Customize next to Keyboard shortcuts in Word Options, Customize Ribbon
  4. In the Customize Keyboard dialog box that pops up, under Categories, choose Macros
  5. In the Macros list, choose the macro you want
  6. Click in the Press new shortcut key box or press Alt-n
  7. Press the keys you want to use
  8. The default place to Save changes in will probably be the Normal template -- change this if desired
  9. Click the Assign command button in the lower left or press Alt-a

    Customize Keyboard in Word to run macros
  10. Assign more shortcuts if you want and then Close the dialog box.

Goto Top  

Reference

Microsoft

View.FieldShading property (Word)

View object (Word)

With the view object, you can set other properties such as zoom, bookmarks, comments, field codes, and a lot more.

Ms Access Gurus

Word Automation VBA Code

Goto Top  

Backstory

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

Share with others

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

Get help automating Word from Access

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.com

~ crystal

the simplest way is best, but usually the hardest to see

Goto Top