Creating a simple add-in.

  • Thread starter Thread starter Dan Berachowitz via OfficeKB.com
  • Start date Start date
D

Dan Berachowitz via OfficeKB.com

Hi

I would like to build an add-in that will create a textbox and a button in
the outlook toolbar , and when I press on the button, it will add a new
contact with my details.
How do I do that? it supposed to be very easy..

Thanks!!
Dan
 
I downloaded all the files but I dont know what to do with it...
 
Hello Dan,

maybe this is a simple solution for you, it's not an AddIn, it's just
macros.

Installation:
Start Outlook
Press Alt + F11

DoubleClick on Project | Microsoft Outlook | ThisOutlookSession
Paste in this code:
'--------------------------------------------------
Private Sub Application_Startup()

CreateCommandBar

End Sub
'----------------------------------------------------
then

Click on Module and if there is a Module1 DoubleClick, if not Create a new
one

paste in this code:
'----------------------------------------------------
'This function creates our CommandBar
'It's called from Application.StartUp event in 'ThisOutlookSession'
Public Sub CreateCommandBar()

On Error Resume Next

Dim objCommandBar As CommandBar
Dim objButton As CommandBarButton
Dim objTextBox As CommandBarControl

'Create a new CommandBar
Set objCommandBar = ActiveExplorer.CommandBars.Add("Contacter", , ,
True)
objCommandBar.Visible = True
objCommandBar.Position = msoBarTop

'Create a simple Textbox
Set objTextBox = objCommandBar.Controls.Add(Office.msoControlEdit, , , ,
True)
objTextBox.Caption = "ClickBox"
objTextBox.Tag = "ClickBox"
objTextBox.Width = 200
objTextBox.OnAction = "NewContact"


'Create a nice Button
Set objButton = objCommandBar.Controls.Add(msoControlButton, , , , True)
objButton.Caption = "New Contact"
objButton.Style = msoButtonIconAndCaption
objButton.FaceId = 607

'Tell the Button which Macro has to be called on click...
objButton.OnAction = "NewContact"

' Forget the Objects
Set objButton = Nothing
Set objTextBox = Nothing
Set objCommandBar = Nothing
End Sub

'Here we create our new Contact with Information from Textbox....
Public Sub NewContact()
On Error Resume Next

Dim objTextBox As CommandBarControl
Dim objContact As ContactItem

Application.CreateItem olContactItem
'Get the Textbox
Set objTextBox =
ActiveExplorer.CommandBars("Contacter").FindControl(Tag:="ClickBox")

Set objContact = Application.CreateItem(olContactItem)
objContact.FullName = objTextBox.Text
objContact.Display

Set objContact = Nothing
Set objTextBox = Nothing
End Sub
'----------------------------------------------------

The Textbox however needs to press enter to get the text.
I Programmed so that if you press enter the contact is created.

P.S. learned from Sue ;-)

--
regards

Helmut Obertanner
Technical Consultant

Softwaredevelopment
DATALOG Software AG | Zschokkestr. 36 | D-80687 Munich
web: www.datalog.de


.... and IT works!
 
Back
Top