Help! Trying to recreate msoControlSplitDropdown type control

K

Kristy

Hi

I have created a load of HTML Templates that I save to a specified
directory. I have created my own toolbar and I have a "New" button
which contains my "default" template. Ideally, then I would use a
msoControlSplitDropdown control so that I could view (and select) any
of the other .ofts in the directory if required. Since I do not have
access to that type of control, I am trying to recreate it and I seem
to have got myself in a real pickle and need some good advice on how I
actually should be going about it?

Code below is what I have tried so far...

Note: I decided to try using a CommandBarPopup and adding
CommandBarButtons to it because I like the way this type of control
looks, I really want it to look like a msoControlSplitDropdown, ie,
nice and compact! Originally I did use a combobox, and it worked well
but it looked so big and cumbersome next to my "New" button, basically
my toolbar started taking up 2 rows (I also use reply/replyall and
forward templates).

I'd really like to know if it is possible to recreate a
msoControlSplitDropdown type control, and if it is advice/example and
how to go about it?


Private NewTemplates As Office.CommandBarPopup
Private WithEvents cbbNewCustomCombo As Office.CommandBarButton

'I use a UDT to store template info

Private Type typNewTemplates
strNewTemplate As String
strNewPath As String
End Type

'declare an array and a count variable
Dim CustomNewTemplates() As typNewTemplates
Dim NumNewTemplates As Integer
Dim AddNewTemplate As Long

'use a function to set up an array
Private Function AddNewTemplates(newTemp As String, newPth As String)
As Long
ReDim Preserve CustomNewTemplates(NumNewTemplates) As
typNewTemplates

With CustomNewTemplates(NumNewTemplates)
.strNewTemplate = newTemp
.strNewPath = newPth
End With

NumNewTemplates = NumNewTemplates + 1
AddNewTemplate = NumNewTemplates


End Function

'Trap click events so that I can load the correct template when
selected

Private Sub cbbNewCustomCombo_Click(ByVal Ctrl As
Office.CommandBarButton, CancelDefault As Boolean)
LoadTemplate
End Sub

And then call from Sub as follows...

Dim sStr As String
Dim sname As String
Dim lLen As Integer
Dim sPath As String

'New Templates

sPath = CustomNewTemps
sStr = Dir(CustomNewTemps & "*.oft")


Do While sStr <> ""

lLen = Len(sStr)
sname = Left(sStr, (lLen - 4))
AddNewTemplates sname, sPath
sStr = Dir()

Loop



Set NewTemplates = cbrFMMExpl.Controls.Add(msoControlPopup, , , 2,
True)
With NewTemplates
.Caption = " "
.Tag = "New Templates"
.ToolTipText = "New Templates"
.BeginGroup = True
End With


Set cbbNewCustomCombo = cbrFMMExpl.FindControl(Type:=msoControlPopup)
If cbbNewCustomCombo Is Nothing Then
For i = 0 To UBound(CustomNewTemplates)

Set cbbNewCustomCombo =
NewTemplates.Controls.Add(msoControlButton, , , , True)

With cbbNewCustomCombo
.Enabled = True
.Visible = True
.Caption = CustomNewTemplates(i).strNewTemplate
.Tag = CustomNewTemplates(i).strNewTemplate
.Style = msoButtonCaption
.OnAction = "!<" & gstrProgId & ">"
End With

Next
End If


Basically this creates a list of all the files in the directory as
required, and it looks OK too! But because of the way it is set up I
only get the click event for cbbNewCustomCombo on the last file added
(since I keep overwritting it, I guess that's to be expected). Alas I
can't declare with events for every file!

I just can't get my head around the best way to do this, can someone
please Help!

Thanks

Kris
 

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