[mso] Re: Help with some Code in Word

Geoff-

You will need to keep the name of your Macro as SymbolCarousel, or just
change it in the code below. It's not exactly all that you want but it
will work to change the R to Red, A to Amber and so on.

-Anthony



Sub SymbolCarousel()

Dim Color 'array for split string
Dim ColorValue 'for the array bit we want

'split the string into bits and take the bit we want
Color =3D Split(Right(Selection.Fields(1).Code.Text,
InStr(Selection.Fields(1).Code.Text, "SymbolCarousel")), " ")
ColorValue =3D Color(1)

'look at what we have and change it to what we want
'we need to change the entire field code though
If ColorValue =3D "Red" Then
    Selection.Fields(1).Code.Text =3D " MACROBUTTON  SymbolCarousel Gold =
"
End If

If ColorValue =3D "Gold" Then
    Selection.Fields(1).Code.Text =3D " MACROBUTTON  SymbolCarousel =
Green
"
End If

If ColorValue =3D "Green" Then
    Selection.Fields(1).Code.Text =3D " MACROBUTTON  SymbolCarousel ? "
End If

If ColorValue =3D "?" Then
    Selection.Fields(1).Code.Text =3D " MACROBUTTON  SymbolCarousel Red =
"
End If

End Sub

-----Original Message-----
From: mso-bounce@xxxxxxxxxxxxx [mailto:mso-bounce@xxxxxxxxxxxxx] On
Behalf Of Geoff Culbertson
Sent: Thursday, April 19, 2007 5:40 PM
To: mso@xxxxxxxxxxxxx
Subject: [mso] Help with some Code in Word

I am starting to learn a little about Visual Basic code but have a long
way to go yet!
=3D20

I have found some code and adapted it for my purposes and use it in a
table.
The code  is shown below:-

=3D20

Select Case Selection.Fields(1).Code.Characters(29)

  Case "?"

    Selection.Fields(1).Code.Characters(29) =3D3D "R"

    Selection.Fields(1).Code.Characters(29).Font.Color =3D3D wdColorRed

  Case "R"

    Selection.Fields(1).Code.Characters(29) =3D3D "A"

    Selection.Fields(1).Code.Characters(29).Font.Color =3D3D wdColorGold

  Case "A"

    Selection.Fields(1).Code.Characters(29) =3D3D "G"

    Selection.Fields(1).Code.Characters(29).Font.Color =3D3D
wdColorBrightGreen

  Case "G"

    Selection.Fields(1).Code.Characters(29) =3D3D "?"

    Selection.Fields(1).Code.Characters(29).Font.Color =3D3D
wdColorAutomatic

  Case Else

End Select

When the code is called by a field cell it shows a ?, which when
double-clicked toggles through R, A, G then back to ?. What I would like
to happen is that the R, A, G should read Red, Amber & Green, however
when I change the letters to the words the code fails to work. Can
anyone help please?

What would be even better for me is if the when the R(ed) was selected
the shading of the cell became red, or when A(mber) was selected the
shading became amber etc. Am I being too hopeful?!

Regards


Geoff Culbertson

Petersfield, Hampshire, UK


*************************************************************
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 share files with the group, you must join our Yahoo sister group. 
 This group will not allow for posting of emails, but will allow you to join 
and share problem files, templates, etc.:  
http://tech.groups.yahoo.com/group/MicrosoftOffice . This group is for FILE 
SHARING ONLY.

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: