Clearing ComboBox in Power point

Hi All,
I have two ComboBox in a macro-enabled powerpoint presentation. These Combobox represent a start-date and an end-date. The following piece of code clears the combobox, but not if the presentation opens with dates already present. So let's say you open the power point presentation, and the dates from when the presentation was previously given were still in the Combobox, if I try to apply this code...nothing happens. But if I adjust the dates in the combo box and apply the code again, it works and the combobox's are cleared. Strange! Any ideas?
Dim j As Long
Dim cb As Object

For j = 1 To 2
Set cb = Slide1.Shapes("ComboBox" & j).OLEFormat.Object
cb.Clear
Next j

'Clean up
 Set cb = Nothing

I am aware it is possible to clear these combo box by utilising the above with  PresentationOpen(ByVal Pres As Presentation) , but this requires an add-in. Is it possible to do this without an add-in? If so, how? Associate it with another event?
tom yAsked:
Who is Participating?
 
Rgonzo1971Connect With a Mentor Commented:
Hi,

pls try
Dim j As Long
Dim cb As Object

For j = 1 To 2
Set cb = Slide1.Shapes("ComboBox" & j).OLEFormat.Object
cb.Value = ""
Next j

'Clean up
 Set cb = Nothing

Open in new window


Regards
1
 
tom yAuthor Commented:
worked like a dream...D'oh. Should have thought of that!
0
 
tom yAuthor Commented:
Possibly we should use vbNullString instead of ""
0
 
Rgonzo1971Commented:
If you prefer, it should work as well
0
 
tom yAuthor Commented:
It does, cheers
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.