Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

VBA to display text based on a merge field value

Posted on 2004-10-20
3
Medium Priority
?
459 Views
Last Modified: 2012-08-14
In a mail merge document, I have a word "if" field that is setup as follows:
      Field name: EmployeeStatus  (this is a merge field)
      Comparison: Equal to
      Compare to: "N"
      Insert this text: "Non Exception"
      Otherwise insert this text: "Exception"

This works great except now I need to expand it so additional values for EmployeeStatus can be handled.  The next step (I am guessing) is to add a vba subroutine to contain a case statement something like:

Sub ConvertStatus()
      Select Case ActiveDocument.FormField.EmployeeStatus
               Case "N"
                     ActiveDocument.FormField.StatusText = "Non Exception"
               Case "E"
                        ActiveDocument.FormField.StatusText = "Exception"
               Case "X"
                        ActiveDocument.FormField.StatusText = "Exempt"
               Case "T"
                        ActiveDocument.FormField.StatusText = "Terminated"
               Case "R"
                     ActiveDocument.FormField.StatusText = "Retired"
      End Case
End Sub


Is this possible? or is the a better solution? I new to using vba with Word and need help. Any suggestions or comments would be greatly appreciated.

Thank you,
Cheri
0
Comment
Question by:Cheri Sheffield
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 76

Accepted Solution

by:
GrahamSkan earned 2000 total points
ID: 12362787
You can nest IF fields, so you don't need VBA
{IF EmployeStatus  = "N" "Non Exception" { IF EmployeeStatus  = "E" "Exception" { IF EmployeeStatus  = "X" "Exempt"...      }}}}}
 
Use ctrl-F9 to insert the field delimeters (displayed as parentheses)
0
 

Author Comment

by:Cheri Sheffield
ID: 12363103
GrahamSkan:

Thank you so so much for your GREAT & quick answer.  You have really helped me out with this.
0
 
LVL 76

Expert Comment

by:GrahamSkan
ID: 12363180
Thanks Cheri,

Your appreciation is most welcome

Graham
0

Featured Post

Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Nice table. Huge mess. Maybe this was something you created way back before you figured out tabs or a document you received from someone else. Either way, using the spacebar to separate the columns resulted in a mess. Trying to convert text to t…
This article describes a method of delivering Word templates for use in merging Access data to Word documents, that requires no computer knowledge on the part of the recipient -- the templates are saved in table fields, and are extracted and install…
This video walks the viewer through the process of creating a watermark for their document, customizing it, and saving it for viewing/printing needs.
Office 365 is currently available in five editions. Three of them are for business use: Office 365 Business Essentials, Office 365 Business, and Office 365 Business Premium. Two of them are for home/personal use: Office 365 Home and Office 365 Perso…

598 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question