troubleshooting Question

VBScript to add an .oft Form file into a new Outlook Toolbar

Avatar of Rafael Adamska
Rafael AdamskaFlag for Brazil asked on
VB ScriptOutlookVisual Basic ClassicVBA
6 Comments1 Solution265 ViewsLast Modified:
Hi everyone.

     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?

Topic: https://www.experts-exchange.com/questions/25051822/VBScript-needed-for-Outlook-manipulation.html#a26403266

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.'
olkSes.Logon "Outlook"

'Add custom Form
Set fso = CreateObject("Scripting.FileSystemObject")
CurrentDirectory = fso.BuildPath(fso.GetAbsolutePathName("."), "Teste1.oft")
Set objItem = olkApp.CreateItemFromTemplate(CurrentDirectory)
Set objFD = objItem.FormDescription

With objFD
    .DisplayName = "TemplateServiceDesk"
    .PublishForm olPersonalRegistry
End With
objItem.Close olDiscard

On Error Resume Next
'Clear any bars
Set ofcBar = olkApp.ActiveExplorer.CommandBars.Item(CMDBAR_TITLE)
If TypeName(ofcBar) <> "Nothing" Then
    ofcBar.Delete
End If

'New bar
Set ofcBar = olkApp.ActiveExplorer.CommandBars.Add(CMDBAR_TITLE)
With ofcBar
    .Visible = True
End With

'Set Button
Set ofcButton = ofcBar.Controls.Add(msoControlButton)
With ofcButton
     '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
End With


olkSes.Logoff

Set olkSes = Nothing
Set olkApp = Nothing
Set ofcButton = Nothing
Set ofcPopup = Nothing
Set ofcBar = Nothing
Set objFD = Nothing
Set objItem = Nothing
Set fso = Nothing

Open in new window


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!
ASKER CERTIFIED SOLUTION
Chris Raisin
Retired Systems Analyst/Programmer

Our community of experts have been thoroughly vetted for their expertise and industry experience.

Log in to continue reading
Become an EE member today7-DAY FREE TRIAL
Members can start a 7-Day Free trial then enjoy unlimited access to the platform for $9.99/mo
View membership options
Unlock 1 Answer and 6 Comments.
or
Learn why we charge membership fees
We get it - no one likes a content blocker. Take one extra minute and find out why we block content.
See how we're fighting big data
The Value of Experts Exchange in My Daily IT Life

Experts Exchange (EE) has become my company's go-to resource to get answers. I've used EE to make decisions, solve problems and even save customers. OutagesIO has been a challenging project and... Keep reading >>

Mike

Owner of Outages.IO
Phoenix, Arizona, United States
Member Since 2016
Join a full scale community that combines the best parts of other tools into one platform.
Unlock 1 Answer and 6 Comments.
View membership options
“All of life is about relationships, and EE has made a virtual community a real community. It lifts everyone's boat.”
William Peck

Member since 2004