samuelwright
11-24-2005, 04:46 AM
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!!:rofl: ). 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:
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
Any ideas?? Thank you!!
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!!:rofl: ). 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:
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
Any ideas?? Thank you!!