PC Review


Reply
Thread Tools Rate Thread

Button To Open Template - Outlook 2003

 
 
Andreich71
Guest
Posts: n/a
 
      24th Jul 2008
I have a form created in .OFT format.
i want to automatically add a button to the main Outlook window that will
open this form.

I can do it manually - be creating a button with "Edit hyperlink" menu
I also found this script:

Sub MakeItem()
Set newItem = Application.CreateItemFromTemplate("c:\your path\open test.oft")
newItem.Display
Set newItem = Nothing
End Sub

 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      25th Jul 2008
If your form has any code in it the form won't run unless it's published.

Otherwise you'd use the ActiveExplorer.CommandBars collection and add a
button to CommandBars("Standard") for adding the button to the Standard
toolbar, to CommandBars("Menu Bar") for a button on the main menu area, etc.

There are lots of examples of adding buttons that way at
www.outlookcode.com. The help in the VBA project for the Object Browser also
has examples for Office.CommandBars, Office.CommandBarButton, etc.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Andreich71" <(E-Mail Removed)> wrote in message
news:8649FB6A-E9D7-4EC6-B5C4-(E-Mail Removed)...
>I have a form created in .OFT format.
> i want to automatically add a button to the main Outlook window that will
> open this form.
>
> I can do it manually - be creating a button with "Edit hyperlink" menu
> I also found this script:
>
> Sub MakeItem()
> Set newItem = Application.CreateItemFromTemplate("c:\your path\open
> test.oft")
> newItem.Display
> Set newItem = Nothing
> End Sub
>


 
Reply With Quote
 
 
 
 
Andreich71
Guest
Posts: n/a
 
      25th Jul 2008
Thanks.
i really found several examples.

This is my compilation:
-------------------------------------------
Option Explicit

Public WithEvents oCBBCustom As Office.CommandBarButton

Private Sub Application_Startup()
Dim oCB As Office.CommandBar
Dim oCBBTools As Office.CommandBarPopup
Set oCB = Application.ActiveExplorer.CommandBars("Standard")

oCB.Reset

Set oCBBCustom = oCB.Controls.Add(msoControlButton, 1, ,
oCB.Controls.Count, True)
With oCBBCustom
.TooltipText = "my_Button"
.BeginGroup = True
.Style = msoButtonIcon
.Picture = LoadPicture("c:\k.bmp")
.Enabled = True
.Visible = True
End With
End Sub

Private Sub oCBBCustom_Click(ByVal Ctrl As Office.CommandBarButton,
CancelDefault As Boolean)
Dim newItem As Variant

Set newItem = Application.CreateItemFromTemplate("c:\wywo\MyForm.oft")
newItem.Display
Set newItem = Nothing
End Sub
-------------------------------------------

And it works fine on machine where I added this code manually in Visual
Basic Editor.
But I wonder what is the best way to distribute this on a several machines?
I need installation to be silent.
If copying of VbaProject.OTM is a best way to do this?
When i copy this file my script doesn't work and I have to copy outcmd.dat
as well.
 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      25th Jul 2008
Deployment of Outlook VBA macros is not recommended and is not a best
practice. You are strongly urged to use a COM addin if you intend to deploy
your code.

There's information at www.outlookcode.com on deploying your code as Outlook
VBA, if you insist on ignoring best practices.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"Andreich71" <(E-Mail Removed)> wrote in message
news:F5069DE4-543F-4406-873D-(E-Mail Removed)...
> Thanks.
> i really found several examples.
>
> This is my compilation:
> -------------------------------------------
> Option Explicit
>
> Public WithEvents oCBBCustom As Office.CommandBarButton
>
> Private Sub Application_Startup()
> Dim oCB As Office.CommandBar
> Dim oCBBTools As Office.CommandBarPopup
> Set oCB = Application.ActiveExplorer.CommandBars("Standard")
>
> oCB.Reset
>
> Set oCBBCustom = oCB.Controls.Add(msoControlButton, 1, ,
> oCB.Controls.Count, True)
> With oCBBCustom
> .TooltipText = "my_Button"
> .BeginGroup = True
> .Style = msoButtonIcon
> .Picture = LoadPicture("c:\k.bmp")
> .Enabled = True
> .Visible = True
> End With
> End Sub
>
> Private Sub oCBBCustom_Click(ByVal Ctrl As Office.CommandBarButton,
> CancelDefault As Boolean)
> Dim newItem As Variant
>
> Set newItem = Application.CreateItemFromTemplate("c:\wywo\MyForm.oft")
> newItem.Display
> Set newItem = Nothing
> End Sub
> -------------------------------------------
>
> And it works fine on machine where I added this code manually in Visual
> Basic Editor.
> But I wonder what is the best way to distribute this on a several
> machines?
> I need installation to be silent.
> If copying of VbaProject.OTM is a best way to do this?
> When i copy this file my script doesn't work and I have to copy outcmd.dat
> as well.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Button To Open Template - Outlook 2007 garfong Microsoft Outlook VBA Programming 13 20th May 2011 10:08 PM
How do I install a "file open" button in the Outlook 2007 button b =?Utf-8?B?TWlzc291bGE=?= Microsoft Outlook Discussion 1 27th Feb 2007 04:39 PM
How to Open Template as Template NOT as '.doc' ? cole.simonson@starwoodvo.com Microsoft Word Document Management 18 27th Jun 2006 12:13 AM
How to Open Template as Template NOT as '.doc' ? cole.simonson@starwoodvo.com Microsoft Word Document Management 0 26th Jun 2006 06:51 PM
open document based on a template ties up that template Tim Wallin Microsoft Word Document Management 1 8th Apr 2005 10:49 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 01:18 AM.