A Microsoft Outlook email forum. Outlook Banter

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » Outlook Banter forum » Microsoft Outlook Email Newsgroups » Outlook and VBA
Site Map Home Register Authors List Search Today's Posts Mark Forums Read Web Partners

Button To Open Template - Outlook 2003



 
 
Thread Tools Search this Thread Display Modes
  #1  
Old July 24th 08, 05:25 PM posted to microsoft.public.outlook.program_vba
Andreich71
external usenet poster
 
Posts: 2
Default Button To Open Template - Outlook 2003

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

Ads
  #2  
Old July 25th 08, 02:59 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Button To Open Template - Outlook 2003

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" wrote in message
...
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


  #3  
Old July 25th 08, 05:17 PM posted to microsoft.public.outlook.program_vba
Andreich71
external usenet poster
 
Posts: 2
Default Button To Open Template - Outlook 2003

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.
  #4  
Old July 25th 08, 09:53 PM posted to microsoft.public.outlook.program_vba
Ken Slovak - [MVP - Outlook]
external usenet poster
 
Posts: 5,848
Default Button To Open Template - Outlook 2003

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" wrote in message
...
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.


 




Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

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

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Button To Open Template - Outlook 2007 garfong Outlook and VBA 7 May 22nd 08 10:37 AM
Outlook 2003 - Button to add body text to an OPEN email Patrick Pirtle Outlook and VBA 5 September 14th 07 04:15 PM
OFT Files won't open correctly - email instead of template Tmuldoon Outlook - Using Forms 1 April 23rd 07 10:48 PM
How do i open a word template from within a contact in Outlook 200 Mark Outlook - Using Contacts 3 July 28th 06 09:48 PM
Outlook 2000 - Button to run Macro then open Database David C Outlook and VBA 1 January 25th 06 04:44 PM


All times are GMT +1. The time now is 09:08 PM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.Search Engine Friendly URLs by vBSEO 2.4.0
Copyright ©2004-2025 Outlook Banter.
The comments are property of their posters.