Consulting

Results 1 to 4 of 4

Thread: Solved: Distributing Outlook Macros

  1. #1

    Solved: Distributing Outlook Macros

    Hello all!!

    Hope you are all well

    I have created a piece of code that semi-automatically populates the subject field of the New Mail Message (with a lot of help from previous VBAX threads!! ). When I open a new Message in Outlook, I have put a button on the toolbar that launches the form that does the action above.

    My friends/colleagues have seen this and are jealous because they spend all their time manually typing all the required information in!! How can I distribute this to them in a user friendly manner? I have tried saving a Outlook Template, hoping that the VB would be embedded when I send the template as an attachment, but to no avail? The code I have is written below:

    [VBA]
    Public objNewMail As Outlook.MailItem

    Sub SubjectName() ' This is the Macro that is called when I click the button
    'that I have put on the Outlook New Message Toolbar
    SubjectNameForm.Show
    End Sub

    '---This is the code for a UserForm called SubjectNameForm with Textboxes
    '---called SaveDate, Title and FileName. A ComboBox Called Class and a
    '---TickBox called InterNetTick, 2 buttons called Ok and Cancel

    Option Explicit

    Dim TodayDate As String
    Dim marker as string
    Dim internetauthorised As String
    Dim replysubject As String

    '---UserForm Set Up
    Private Sub UserForm_Initialize()
    Set objNewMail = Outlook.ActiveInspector.CurrentItem
    replysubject = ""

    '---Sets Date
    SaveDate = Format(Date, "yyyymmdd")

    '---Sets Classification menu
    Class.AddItem ("D - Draft")
    Class.AddItem ("F - Final")

    '---If Email is a Re/Fwd, ensures email does not start with RE:FW etc
    If Left(objNewMail.Subject, 3) = "RE:" _
    Or Left(objNewMail.Subject, 3) = "FW:" _
    Then Title = objNewMail.Subject
    End Sub

    Private Sub Title_Enter()
    If SubjectNameForm.Title.BackColor <> RGB(255, 255, 255) Then
    SubjectNameForm.Title.BackColor = RGB(255, 255, 255)
    Title = ""
    End If
    End Sub

    Private Sub Update_Filename()

    marker = Left(Class, 1)

    If InternetTick.Value = True Then _
    internetauthorised = "Internet-Authorised:"
    Else internetauthorised = ""
    FileName = internetauthorised & SaveDate & " " _
    & marker & " " & Title
    End Sub

    Private Sub Title_Change()
    Call Update_Filename
    End Sub

    Private Sub SaveDate_Change()
    Call Update_Filename
    End Sub

    '---Gathers all the infomation from the options and
    '---presents it to the subject line
    Private Sub okButton_click()
    objNewMail.Subject = FileName
    Unload Me
    End Sub

    '---This button exits the form

    Private Sub CancelButton_Click()
    Unload Me
    End Sub

    [/VBA]

    Any ideas?? Thank you!!

  2. #2
    VBAX Mentor
    Joined
    Sep 2004
    Location
    Nashua, NH, USA
    Posts
    489
    Location
    There's no user friendly way to distribute Outlook code.
    Unlike Word, which allows multiple templates, and Excel, which allows multiple workbooks, Outlook allows only a single VBAproject.otm file.

    If a user has no VBAproject.otm file, then you can give them a copy of yours.

    If they already have the .otm file, then, if you are distributing source code, the usual techniques for importing code and manual entering code and project references can be used.

    If you are not distributing source code, then you have to distribute either an ActiveX DLL or COM add-in, and tell the user how to install each.

    Alas, Outlook object model is brain-dead, e.g., it does not expose the VBProject object so you cannot even program a setup program to do things for the user.

    Best places to look for info are www.slipstick.com and www.outlookcode.com.

  3. #3
    Howard

    Is it possible to do what I want to do using a Form rather than a macro? Ie design a form where instead of the Subject Caption label, I have a button which when pressed, brings up a UserForm? That way I could email the form around.

    Sam

  4. #4
    I haved plumped with distributing the VBAProject.OTM file and depositing it in their User Outlook Settings. This seems to work ok, except if they use Outlook 2000, because 2003 Reference Library is not available on 2000. I have put a new post up with this problem:

    http://vbaexpress.com/forum/showthread.php?t=6335

    Thanks for your advice, I will mark this thread solved.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •