comparing a combo box values with text box values

J

Julied_ng

with assistance from Chirag (on this group) to an earlier question i
now have the following code ...
----
For Each Shp In Sld.Shapes
If Shp.Type = msoOLEControlObject Then
If Shp.OLEFormat.ProgID = "Forms.ComboBox.1" Then
Set Control = Shp.OLEFormat.Object
'this is where i need help
End If
End If
End If
Next
-----

what the code is doing is cycling through all the shapes on a slide and
if it is a combobox looking more closly at it. What i want to do now
is compare the value in that combobox with a textbox value.

However, i have 5 comboboxes and 5 associated textboxes. The textboxes
are name "txtA111", "txtA112" ... "txtA115" and i want to compare
combobox "cboA111" with "txtA111" and combobox "cboA112" with "txtA112"
etc

how can i write the code to compare these two objects without having to
use a select case or if / elseif statement looking at each combination
in turn?

hope this makes sense!

Cheers
JulieD
 
C

Chirag

See if the following code helps you:

---
Private ComboBoxes As Collection
Private TextBoxes As Collection

Sub CollectBoxes(ByVal Sld As Slide)
Dim Shp As Shape

For Each Shp In Sld.Shapes
If Shp.Type = msoOLEControlObject Then
If Shp.OLEFormat.ProgID = "Forms.ComboBox.1" Then
ComboBoxes.Add Shp, Shp.Name
ElseIf Shp.OLEFormat.ProgID = "Forms.TextBox.1" Then
TextBoxes.Add Shp, Shp.Name
End If
End If
Next
End Sub

Sub CompareTextInBoxes()
Dim I As Long

For I = 1 To ComboBoxes.Count
If ComboBoxes(I).OLEFormat.Object.Value = _
TextBoxes(I).OLEFormat.Object.Value Then
'...
End If
Next
End Sub

Sub Test()
Set ComboBoxes = New Collection
Set TextBoxes = New Collection

CollectBoxes ActivePresentation.Slides(1)
CompareTextInBoxes

Set ComboBoxes = Nothing
Set TextBoxes = Nothing
End Sub
---

- Chirag

PowerShow - View multiple PowerPoint slide shows simultaneously
http://officeone.mvps.org/powershow/powershow.html
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top