I'm trying to develop a code in VBScript (.vbs file) that adds a button on Outlook (2010) and runs a custom form (already developed, .oft file) that is on teh same directory as the .vbs file.
I have to install this button and custom form to more than one computer, so the ideia is that the VBScript install the .oft file permanently, so the user could access that form by pressing the new button without have to execute the .vbs file or install the form again.
I'm halfway there, I was looking to this other topic, but I couldn't install the .oft Form with that. Could someone please point me the right direction to finish this VBScript?
What I've got so far:
Const msoControlButton = 1
Const msoCommandBarButtonHyperlinkOpen = 1
'Change the toolbar name on the next line as desired.'
Const CMDBAR_TITLE = "Service Desk Bar"
Dim objItem ' As Outlook.ContactItem
Dim objFD ' As Outlook.FormDescription
Dim fso ' As FileSystemObject
Dim olkApp, olkSes, ofcBar, ofcButton
Set olkApp = CreateObject("Outlook.Application") ' As Outlook.Application
Set olkSes = olkApp.GetNamespace("MAPI")
'Change the profile name on the next line as needed.'
'Add custom Form
Set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.BuildPath(fso.GetAbsolutePathName("."), "Teste1.oft")
Set objItem = olkApp.CreateItemFromTemplate(CurrentDirectory)
Set objFD = objItem.FormDescription
.DisplayName = "TemplateServiceDesk"
On Error Resume Next
'Clear any bars
Set ofcBar = olkApp.ActiveExplorer.CommandBars.Item(CMDBAR_TITLE)
If TypeName(ofcBar) <> "Nothing" Then
Set ofcBar = olkApp.ActiveExplorer.CommandBars.Add(CMDBAR_TITLE)
.Visible = True
Set ofcButton = ofcBar.Controls.Add(msoControlButton)
'Change the caption on the next line.'
.Caption = "ABRIR Chamado Service Desk"
.HyperlinkType = msoCommandBarButtonHyperlinkOpen
'Change the path to the template file on the next line.'
.TooltipText = "" 'I DON'T KNOW WHAT TO PUT HERE
.Visible = True
Set olkSes = Nothing
Set olkApp = Nothing
Set ofcButton = Nothing
Set ofcPopup = Nothing
Set ofcBar = Nothing
Set objFD = Nothing
Set objItem = Nothing
Set fso = Nothing
Now the other exemple (Link above) gave me the ability to Hyperlink a path to my desktop, for instance. But what I REALLY need is to that button opens the form that is already inside Outlook, on the personal registry!
Thank you all!