[mso] Re: Word & nested IIF

Glenda,
   
  I'm sorry you are experiencing frustration. We sent you textbox code because 
the code sample you provided was for a textbox. As I understand this, you want 
Word to examine each value passed to a particular merge field, and based on 
that value, add/replace text in the merge (main) document. 
   
  This is out of my area of expertise, but I think you need to put the Select 
Case statement inside a MailMergeBeforeRecordMerge event. I am trying to create 
a working code sample for you (not quite there yet).  :^(
   
  Has anybody else worked with the MailMergeBeforeRecordMerge or other 
MailMerge events?
   
  Regards,
   
  Hutch
  
GLENDA WELLS <gwells58@xxxxxxx> wrote:
  it's so frustrating not having a clue as to what i'm doing!

does it need to be a text box? is there some way i can just have it happen 
on the merge document instead?

i used the VB editor to write it and what i don't get is how does the 
statement know where the value of state is coming from? i have state as a 
merge field <>


>From: Thomas Hutchins 
>Reply-To: mso@xxxxxxxxxxxxx
>To: mso@xxxxxxxxxxxxx
>Subject: [mso] Re: Word & nested IIF
>Date: Wed, 10 May 2006 12:18:39 -0700 (PDT)
>
>If the textbox is on the document itself, rather than on a userform, it 
>won't have an Exit event. In this case, the LostFocus event will give the 
>same result. Just replace
> TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean) with
> TextBox1_LostFocus()
>
> Regards,
>
> Hutch
>
>Genevieve wrote:
> Hello Glenda,
>
>First you have a typo I guess, you cannot use sub a() after your line 
>private sub textbox1_change.
>Second, are you sure you want to use the change event?? and not the exit 
>event for example??? (change event will fire every single key pressed in 
>the textbox1!!!)
>Third, actually, things are happening with your code but you cannot see 
>anything because you are only changing the value of the variable state but 
>not displaying anything.
>Try the following. Maybe it will help you
>
>Private Sub TextBox1_Exit(ByVal Cancel As MSForms.ReturnBoolean)
>Dim state As String
>state = UCase(TextBox1.Text)
>
>Select Case state
>Case "IL"
>MsgBox state & " is a great place to be from"
>Case "FL"
>MsgBox state & " is too hot & muggy"
>Case "MO"
>MsgBox state & " is prolly too tame for a city kid"
>Case ""
>MsgBox "no state entered"
>Case Else
>MsgBox "No Valid State"
>End Select
>End Sub
>
>
>Genevieve
>GLENDA WELLS wrote:
>I've only written a minor VB statement or two with the help of this list so
>forgive my fumbling.
>
>In my merge doc I wrote this. It does nothing so I'm obviously not doing it
>right. state is one of the variables on my excel data file and is in the
>document as a merge field.
>
>Private Sub TextBox1_Change()
>Sub a()
>Dim state As String
>state = "IL"
>
>Select Case state
>Case "IL"
>state = "il is a great place to be from"
>
>Case "FL"
>state = "fl is too hot & muggy"
>Case "MO"
>state = "mo is prolly too tame for a city kid"
>
>Case Else
>MsgBox "No State Entered"
>End Select
>End Sub
>
>
>
> >From: "David Smart"
> >Reply-To: mso@xxxxxxxxxxxxx
> >To:
> >Subject: [mso] Re: Word & nested IIF
> >Date: Thu, 11 May 2006 00:31:15 +1000
> >
> >This from the Excel VBE, but word should be the same
> >
> >Sub a()
> > Dim Abc As String
> > Abc = "Fred"
> > Dim City As String
> > Select Case Abc
> > Case "Joe"
> > City = "Sydney"
> > Case "Fred", "Jim"
> > City = "Melbourne"
> > Case Else
> > MsgBox "Haven't heard of this guy"
> > End Select
> >End Sub
> >
> >The Select Case is a nice easy way to select between similar things 
>without
> >a chain of nested IF's.
> >
> >Regards, Dave S
> >----- Original Message -----
> >From: "GLENDA WELLS"
> >To:
> >Sent: Wednesday, May 10, 2006 11:38 PM
> >Subject: [mso] Re: Word & nested IIF
> >
> >
> > > do you have an example David? I looked up CASE in the help and got a
> > > bunch
> > > of references to Japanese text and CD Jewel Case design. On the web I
> >got
> > > a
> > > lot ov VB that wasn't very clear to me.
> > >
> > >
> > >>From: "David Smart"
> > >>Reply-To: mso@xxxxxxxxxxxxx
> > >>To:
> > >>Subject: [mso] Re: Word & nested IIF
> > >>Date: Wed, 10 May 2006 20:31:16 +1000
> > >>
> > >>I'm coming in very late on this thread, but ...
> > >>
> > >>The other alternative to nested IF's is select case. If you are 
>wanting
> > >>to
> > >>act on multiple values that can be in a variable, the old case 
>statement
> > >>is
> > >>often the way to go.
> > >>
> > >>Regards, Dave S
> > >>----- Original Message -----
> > >>From: "GLENDA WELLS"
> > >>To:
> > >>Sent: Wednesday, May 10, 2006 7:56 AM
> > >>Subject: [mso] Word & nested IIF
> > >>
> > >>
> > >> > Hi All.
> > >> >
> > >> > I had requested suggestions on whether or not to use nested IF in
> >Word
> > >>to
> > >> > tell a merge document what text to input based on a value in the
> >merge
> > >> > file.
> > >> >
> > >> > Someone here suggested VLOOKUP which I played around with but could
> >not
> > >> > get
> > >> > to work with my scenario.
> > >> >
> > >> > Anyway, the nested IF is working although cumbersome to set up.
> > >> >
> > >> > Sorry I don't have the reference email (MSN deletes everything 
>after
> >5
> > >> > days)
> > >> > but I wanted to let y'all know I made a choice.
> > >> >
> > >> > Thanks. /g
> > >> >
> > >> > _________________________________________________________________
> > >> > FREE pop-up blocking with the new MSN Toolbar - get it now!
> > >> > http://toolbar.msn.click-url.com/go/onm00200415ave/direct/01/
> > >> >
> > >> > *************************************************************
> > >> > You are receiving this mail because you subscribed to
> >mso@xxxxxxxxxxxxx
> > >>or
> > >> > MicrosoftOffice@xxxxxxxxxxxxxxxx
> > >> >
> > >> > To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> > >> >
> > >> > To Unsubscribe from this group, visit the group's homepage and use
> >the
> > >> > dropdown menu at the top. This will allow you to unsubscribe your
> > >> > email
> > >> > address or change your email settings to digest or vacation (no
> >mail).
> > >> > http://www.freelists.org/webpage/mso
> > >> >
> > >> > To be able to use the files section for sharing files with the 
>group,
> > >>send
> > >> > a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an
> > >> > invitation with instructions. Once you are a member of the files
> > >> > group,
> > >> > you can go here to upload/download files:
> > >> > http://www.smartgroups.com/vault/msofiles
> > >> >
> > >> > If you are using Outlook and you see a lot of unnecessary code in
> >your
> > >> > email messages, read these instructions that explain why and how to
> >fix
> > >> > it:
> > >> > http://personal-computer-tutor.com/abc3/v28/greg28.htm
> > >> > *************************************************************
> > >> >
> > >>
> > >>*************************************************************
> > >>You are receiving this mail because you subscribed to 
>mso@xxxxxxxxxxxxx
> >or
> > >>MicrosoftOffice@xxxxxxxxxxxxxxxx
> > >>
> > >>To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> > >>
> > >>To Unsubscribe from this group, visit the group's homepage and use the
> > >>dropdown menu at the top. This will allow you to unsubscribe your 
>email
> > >>address or change your email settings to digest or vacation (no mail).
> > >>http://www.freelists.org/webpage/mso
> > >>
> > >>To be able to use the files section for sharing files with the group,
> >send
> > >>a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an
> > >>invitation with instructions. Once you are a member of the files 
>group,
> > >>you can go here to upload/download files:
> > >>http://www.smartgroups.com/vault/msofiles
> > >>
> > >>If you are using Outlook and you see a lot of unnecessary code in your
> > >>email messages, read these instructions that explain why and how to 
>fix
> > >>it:
> > >>http://personal-computer-tutor.com/abc3/v28/greg28.htm
> > >>*************************************************************
> > >
> > > _________________________________________________________________
> > > Is your PC infected? Get a FREE online computer virus scan from 
>McAfee®
> > > Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963
> > >
> > > *************************************************************
> > > You are receiving this mail because you subscribed to 
>mso@xxxxxxxxxxxxx
> >or
> > > MicrosoftOffice@xxxxxxxxxxxxxxxx
> > >
> > > To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> > >
> > > To Unsubscribe from this group, visit the group's homepage and use the
> > > dropdown menu at the top. This will allow you to unsubscribe your 
>email
> > > address or change your email settings to digest or vacation (no mail).
> > > http://www.freelists.org/webpage/mso
> > >
> > > To be able to use the files section for sharing files with the group,
> >send
> > > a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an
> > > invitation with instructions. Once you are a member of the files 
>group,
> > > you can go here to upload/download files:
> > > http://www.smartgroups.com/vault/msofiles
> > >
> > > If you are using Outlook and you see a lot of unnecessary code in your
> > > email messages, read these instructions that explain why and how to 
>fix
> > > it:
> > > http://personal-computer-tutor.com/abc3/v28/greg28.htm
> > > *************************************************************
> > >
> >
> >*************************************************************
> >You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx 
>or
> >MicrosoftOffice@xxxxxxxxxxxxxxxx
> >
> >To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
> >
> >To Unsubscribe from this group, visit the group's homepage and use the
> >dropdown menu at the top. This will allow you to unsubscribe your email
> >address or change your email settings to digest or vacation (no mail).
> >http://www.freelists.org/webpage/mso
> >
> >To be able to use the files section for sharing files with the group, 
>send
> >a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an
> >invitation with instructions. Once you are a member of the files group,
> >you can go here to upload/download files:
> >http://www.smartgroups.com/vault/msofiles
> >
> >If you are using Outlook and you see a lot of unnecessary code in your
> >email messages, read these instructions that explain why and how to fix 
>it:
> >http://personal-computer-tutor.com/abc3/v28/greg28.htm
> >*************************************************************
>
>_________________________________________________________________
>Express yourself instantly with MSN Messenger! Download today - it's FREE!
>http://messenger.msn.click-url.com/go/onm00200471ave/direct/01/
>
>*************************************************************
>You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
>MicrosoftOffice@xxxxxxxxxxxxxxxx
>
>To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
>
>To Unsubscribe from this group, visit the group's homepage and use the 
>dropdown menu at the top. This will allow you to unsubscribe your email 
>address or change your email settings to digest or vacation (no mail).
>http://www.freelists.org/webpage/mso
>
>To be able to use the files section for sharing files with the group, send 
>a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an 
>invitation with instructions. Once you are a member of the files group, you 
>can go here to upload/download files:
>http://www.smartgroups.com/vault/msofiles
>
>If you are using Outlook and you see a lot of unnecessary code in your 
>email messages, read these instructions that explain why and how to fix it:
>http://personal-computer-tutor.com/abc3/v28/greg28.htm
>*************************************************************
>
>
>
>---------------------------------
>Yahoo! Mail goes everywhere you do. Get it on your phone.
>
>*************************************************************
>You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
>MicrosoftOffice@xxxxxxxxxxxxxxxx
>
>To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
>
>To Unsubscribe from this group, visit the group's homepage and use the 
>dropdown menu at the top. This will allow you to unsubscribe your email 
>address or change your email settings to digest or vacation (no mail).
>http://www.freelists.org/webpage/mso
>
>To be able to use the files section for sharing files with the group, send 
>a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an 
>invitation with instructions. Once you are a member of the files group, you 
>can go here to upload/download files:
>http://www.smartgroups.com/vault/msofiles
>
>If you are using Outlook and you see a lot of unnecessary code in your 
>email messages, read these instructions that explain why and how to fix it:
>http://personal-computer-tutor.com/abc3/v28/greg28.htm
>*************************************************************
>
>
>
>---------------------------------
>Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls. Great rates 
>starting at 1¢/min.
>
>*************************************************************
>You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
>MicrosoftOffice@xxxxxxxxxxxxxxxx
>
>To send mail to the group, simply address it to mso@xxxxxxxxxxxxx
>
>To Unsubscribe from this group, visit the group's homepage and use the 
>dropdown menu at the top. This will allow you to unsubscribe your email 
>address or change your email settings to digest or vacation (no mail).
>http://www.freelists.org/webpage/mso
>
>To be able to use the files section for sharing files with the group, send 
>a request to mso-moderators@xxxxxxxxxxxxx and you will be sent an 
>invitation with instructions. Once you are a member of the files group, 
>you can go here to upload/download files:
>http://www.smartgroups.com/vault/msofiles
>
>If you are using Outlook and you see a lot of unnecessary code in your 
>email messages, read these instructions that explain why and how to fix it:
>http://personal-computer-tutor.com/abc3/v28/greg28.htm
>*************************************************************

_________________________________________________________________
Is your PC infected? Get a FREE online computer virus scan from McAfee® 
Security. http://clinic.mcafee.com/clinic/ibuy/campaign.asp?cid=3963

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top. This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions. Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************


                
---------------------------------
Talk is cheap. Use Yahoo! Messenger to make PC-to-Phone calls.  Great rates 
starting at 1&cent;/min.

*************************************************************
You are receiving this mail because you subscribed to mso@xxxxxxxxxxxxx or 
MicrosoftOffice@xxxxxxxxxxxxxxxx

To send mail to the group, simply address it to mso@xxxxxxxxxxxxx

To Unsubscribe from this group, visit the group's homepage and use the dropdown 
menu at the top.  This will allow you to unsubscribe your email address or 
change your email settings to digest or vacation (no mail).
http://www.freelists.org/webpage/mso

To be able to use the files section for sharing files with the group, send a 
request to mso-moderators@xxxxxxxxxxxxx and you will be sent an invitation with 
instructions.  Once you are a member of the files group, you can go here to 
upload/download files:
http://www.smartgroups.com/vault/msofiles

If you are using Outlook and you see a lot of unnecessary code in your email 
messages, read these instructions that explain why and how to fix it:
http://personal-computer-tutor.com/abc3/v28/greg28.htm
*************************************************************

Other related posts: