How to choose from a list of templates in a shared drive folder

Kieren

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Hi, I have a few issues I'm needing help with but this is the biggest one for me right now.

I'm trying to create something where a user will press a button and have a list of templates in a shared drive folder pop up, which they can select from. The list needs to automatically refresh every time the button is pressed, as templates will be added and removed from that folder.

I assume a combobox form would be a good start to this, but I'm not sure how to proceed. Any help would be appreciated.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
With VBA you cannot add anything to the ribbon. You could add a UserForm to the VBA project, and place a combobox on it. On the QAT you could manually place a button to display the form.
 

Kieren

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
With VBA you cannot add anything to the ribbon. You could add a UserForm to the VBA project, and place a combobox on it. On the QAT you could manually place a button to display the form.
I suppose I wasn't quite clear. I'm having trouble figuring out how to dynamically update a combobox with a list of templates in a file system directory.

As of right now I can use .AddItem and manually add in items to the drop down and then use Case 0, 1, 2 etc to modify a template string to open a specific file in the directory based on what is selected.

What I'm trying to do is have it so the combobox is automatically filled with the list of files in a directory, and selecting that file will open that template. So the combobox will dynamically show what is in the directory rather than having to hardcode in the names and location.

I was using this as a basic: http://www.slipstick.com/developer/code-samples/vba-userform-sample-select-list-templates/
 

Kieren

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Okay, so I have a crude solution to display the files in the combobox using

With ComboBox1
Dim MyFile As String
My File = Dir("Directory Path)
Do While Myfile <> ""
.AddItem MyFile
MyFile = Dir()
Loop
End With
End Sub

Now I need some assistance in selecting the correct template in the folder based on what was selected in the combobox, if someone would be able to help me out with that would be very appreciated!
 

Kieren

New Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Okay got that figure out too lol using strTemplate = UserForm1.ComboBox1.Text
Probably not pretty but it works.

Last thing I need help with here is if there's any way to remove the file name type in the combobox using my above code? Right now it will list things as "Default.oft" etc, I'd like to remove the .oft.
 

Michael Bauer

Senior Member
Outlook version
Outlook 2010 32 bit
Email Account
Exchange Server
Use the InstrRev function. With it find the position of the last dot in the string. Once you know its position, you can use the Left function to return only the part left of the dot.
 
Top