
Signature
Hope this helps.
Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.
Doug Robbins - Word MVP
Both methods work equally as well. Thank-you gentlemen!! Would it
surprise you to know that I've been trying to come up with that on my
own for three days now? I'm new to VBA, so this is really a help.
I have this sub in there as well which I would like to fire for
"Combobox1", but other combobox's as well. Is there a way to make it
portable to new combobox's?
Private Sub ComboBox1_Change()
If ComboBox1.Text = "Addressed" Or ComboBox1.Text = "No Flag" Then
ComboBox1.BackColor = RGB(184, 225, 127)
ComboBox1.ForeColor = RGB(0, 0, 0)
ElseIf ComboBox1.Text = "Follow-Up" Then
ComboBox1.BackColor = RGB(73, 22, 109)
ComboBox1.ForeColor = RGB(255, 255, 255)
ElseIf ComboBox1.Text = "Waiting" Then
ComboBox1.BackColor = RGB(250, 202, 0)
ComboBox1.ForeColor = RGB(0, 0, 0)
End If
End Sub
> This uses the Range object rather than the Selection object
>
[quoted text clipped - 49 lines]
> > Win XP, Office 2003
> > "red.sys" & Chr$(64) & "t-online.de"
Helmut Weber - 16 Sep 2006 20:29 GMT
Hi,
>I have this sub in there as well which I would like to fire for
>"Combobox1", but other combobox's as well. Is there a way to make it
>portable to new combobox's?
writing code which manipulates code is possible, in principle.
You need a reference to the appropriate library.
Which was
microsoft visual basic for applications extensibility library 6.0,
or so, seemably in other versions than the one I got at present,
because I can't it anymore.
But it's hell, I'd say.
I did some experiments with it years ago.
But as it was to me of little practical use,
I forgot about it.
Another way would be, to use a selection-change event
and loop over all inlineshapes of
OLEFormat.ClassType = "Forms.ComboBox.1".
But it would terribly slow down editing. probably.
Maybe feasable for 1 page documents.
Or you mean something like that:
Private Sub ComboBox1_Change()
Combo
End Sub
Private Sub Combo()
Dim oCtrl As InlineShape
For Each oCtrl In ActiveDocument.InlineShapes
If oCtrl.OLEFormat.ClassType = "Forms.ComboBox.1" Then
If oCtrl.OLEFormat.Object.Text = "0001" Then
oCtrl.OLEFormat.Object.BackColor = RGB(184, 225, 127)
oCtrl.OLEFormat.Object.ForeColor = RGB(0, 0, 0)
End If
' ... more conditions and actions
End If
Next
End Sub
I'm at the end of my wisdom, sorry.

Signature
Greetings from Bavaria, Germany
Helmut Weber, MVP WordVBA
Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
Ted Williams - 17 Sep 2006 04:16 GMT
Thank you Helmut, this was actually greatly helpful. I just added a
command button to the form and when it is clicked, your sub is called.
It takes all of the combos and evaluates the text and colours the
accordingly.
Thanks again for taking the time to write good responses. I have
learned! Greetings from Canada.
> Hi,
>
[quoted text clipped - 50 lines]
> Win XP, Office 2003
> "red.sys" & Chr$(64) & "t-online.de"