Can anyone help with this? Original thread included...last post is question.

K

kaiser

kaiser
Oct 26, 1:51 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 25 Oct 2005 22:51:20 -0700
Local: Wed, Oct 26 2005 1:51 pm
Subject: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I am looking to
write somethig for Outlook so that whenever I open a blank email to
send a new email it pops up with a window asking me to select one of
four choices for the subject....is this possible?
If so, can someone give me some guidance on how to do this? thanks! I
am really struggling with it....if anyone can slap a rough version of
it together in 5 minutes or has a procedure that already does this I
would really appreciate seeing it as I really dont know where to start.



Reply





Michael Bauer
Oct 26, 2:30 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Wed, 26 Oct 2005 08:30:47 +0200
Local: Wed, Oct 26 2005 2:30 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 25 Oct 2005 22:51:20 -0700 schrieb kaiser:


It will take you a little more than 5 minutes but it´s easy. Add an
UserForm
to your VBA project. If you´re sure you´ll stick with a specified and
little
number of choices I´d use e.g. 4 Option (or Radio) Buttons on it. If
the
number of choices can increase then I´d use a ComboBox.


Call UserForm.Show 1 from within the NewInspector event and if the user

clicks the OK button on your UserForm then read which choice is
selected.


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
I am looking to
write somethig for Outlook so that whenever I open a blank email to
send a new email it pops up with a window asking me to select one of
four choices for the subject....is this possible?
If so, can someone give me some guidance on how to do this? thanks! I
am really struggling with it....if anyone can slap a rough version of
it together in 5 minutes or has a procedure that already does this I
would really appreciate seeing it as I really dont know where to start.


Reply





kaiser
Oct 26, 2:34 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 25 Oct 2005 23:34:32 -0700
Local: Wed, Oct 26 2005 2:34 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Thanks Michael - appreciate your answer....can you help me with the
code for the NewInspector? I am lost without the Macro Recorder
unfortunately.


Reply





Michael Bauer
Oct 26, 3:19 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Wed, 26 Oct 2005 09:19:51 +0200
Local: Wed, Oct 26 2005 3:19 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 25 Oct 2005 23:34:32 -0700 schrieb kaiser:


Private WithEvents m_colInspectors As Outlook.Inspectors


Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub


Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString then
' call now your form
Endif
Endif
End Sub


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
Thanks Michael - appreciate your answer....can you help me with the
code for the NewInspector? I am lost without the Macro Recorder
unfortunately.


Reply





kaiser
Oct 26, 3:23 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 00:23:00 -0700
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

THanks M...when i copy and paste this into my VBA editor (in a module)
i am presented with the error


"Only Valid in an Object Module"


Reply





Michael Bauer
Oct 26, 3:58 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Wed, 26 Oct 2005 09:58:42 +0200
Local: Wed, Oct 26 2005 3:58 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 26 Oct 2005 00:23:00 -0700 schrieb kaiser:


That´s correct, events can be received in object module only. You can
use
the ThisOutlookSession module e.g.


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
THanks M...when i copy and paste this into my VBA editor (in a module)
i am presented with the error
"Only Valid in an Object Module"



Reply





kaiser
Oct 26, 4:19 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 01:19:41 -0700
Local: Wed, Oct 26 2005 4:19 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

I am sorry to be a pain but I cant seem to get it working. I have
dropped the text into the
"ThisOutLookSession" under Microsoft Office Outlook Objects and it now
doesnt come up with an error. I have also created a userform UserForm1

and tried to call it within the procedure from under the
ThisOUtlookSession window...but nothing is happening


Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.Show
End If
End If
End Sub


Reply





Michael Bauer
Oct 26, 7:35 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Wed, 26 Oct 2005 13:35:41 +0200
Local: Wed, Oct 26 2005 7:35 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 26 Oct 2005 01:19:41 -0700 schrieb kaiser:


After copying my sample into ThisOutlookSession please save the
project,
place the cursor into the Application_Startup event and press F5. While

developing the code you´ll need to re-start Application_Startup after
every
code changes (either manually as explained or by closing and re-opening

Outlook itself).


The NewInspector event then should be executed if you´re opening an
item.


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
I am sorry to be a pain but I cant seem to get it working. I have
dropped the text into the
"ThisOutLookSession" under Microsoft Office Outlook Objects and it now
doesnt come up with an error. I have also created a userform UserForm1
and tried to call it within the procedure from under the
ThisOUtlookSession window...but nothing is happening
Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.Show
End If
End If
End Sub



Reply





kaiser
Oct 26, 7:52 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 04:52:16 -0700
Local: Wed, Oct 26 2005 7:52 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Fantastic! Thank you for your help....much apprecaited


Reply





kaiser
Oct 26, 7:54 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 04:54:43 -0700
Local: Wed, Oct 26 2005 7:54 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

It seems to run once only though...so if I place the code as you
suggest and then run the application (as you sugges) and open an email
it prompts me for my choice, however, if I choose an option and then
open another email it doesnt prompt me for a input unless I rerun the
program with F5 in the Startup


Reply





kaiser
Oct 26, 7:55 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 04:55:08 -0700
Local: Wed, Oct 26 2005 7:55 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

It seems to run once only though...so if I place the code as you
suggest and then run the application (as you sugges) and open an email
it prompts me for my choice, however, if I choose an option and then
open another email it doesnt prompt me for a input unless I rerun the
program with F5 in the Startup


Reply





Michael Bauer
Oct 27, 5:33 am show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Wed, 26 Oct 2005 23:33:16 +0200
Local: Thurs, Oct 27 2005 5:33 am
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 26 Oct 2005 04:54:43 -0700 schrieb kaiser:


Please show the code.


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
It seems to run once only though...so if I place the code as you
suggest and then run the application (as you sugges) and open an email
it prompts me for my choice, however, if I choose an option and then
open another email it doesnt prompt me for a input unless I rerun the
program with F5 in the Startup


Reply





kaiser
Oct 27, 1:11 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 22:11:39 -0700
Local: Thurs, Oct 27 2005 1:11 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Below in ThisOUtlookSession


Private WithEvents m_colInspectors As Outlook.Inspectors


Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub


Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.Show
End If
End If
End Sub


And this as the form (which doesnt work either : perhaps you can help
me too?)
Private Sub CommandButton1_Click()
With UserForm1


Dim oItem As Outlook.MailItem


If .OptionButton1.Value = True Then oItem.Subject = "Test"


UserForm1.Hide
End With


End Sub


Private Sub Frame1_Click()


End Sub


Private Sub OptionButton1_Click()


End Sub


Private Sub OptionButton2_Click()


End Sub


Private Sub OptionButton3_Click()


End Sub


Private Sub UserForm_Click()


End Sub


Reply





Michael Bauer
Oct 27, 2:31 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Thu, 27 Oct 2005 08:31:49 +0200
Local: Thurs, Oct 27 2005 2:31 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 26 Oct 2005 22:11:39 -0700 schrieb kaiser:


Please try this:


<ThisOutlookSession>
Option Explicit
Private WithEvents m_colInspectors As Outlook.Inspectors
Private WithEvents CurrentInspector As Outlook.Inspector


Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub


Private Sub CurrentInspector_Activate()
Dim oMail As Outlook.MailItem
If Len(UserForm1.SelectedSubject) Then
Set oMail = CurrentInspector.CurrentItem
oMail.Subject = UserForm1.SelectedSubject
End If
Set CurrentInspector = Nothing
End Sub


Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.SelectedSubject = vbNullString
UserForm1.Show
Set CurrentInspector = Inspector
End If
End If
End Sub
</ThisOutlookSession>


<UserForm1>
Option Explicit
Public SelectedSubject As String


Private Sub CommandButton1_Click()
If OptionButton1.Value = True Then
SelectedSubject = "Test"
End If
Hide
End Sub
</UserForm1>


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
Private WithEvents m_colInspectors As Outlook.Inspectors
Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub

Private Sub m_colInspectors_NewInspector(ByVal Inspector As
Outlook.Inspector)
If TypeOf Inspector.CurrentItem Is Outlook.MailItem Then
If Inspector.CurrentItem.EntryID = vbNullString Then
UserForm1.Show
End If
End If
End Sub



Reply





kaiser
Oct 27, 2:52 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 26 Oct 2005 23:52:20 -0700
Local: Thurs, Oct 27 2005 2:52 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Fantastic! It works perfectly! Thank you very very much for all your
help.


If I want to send this to someone who is very computer illiterate so
that they can use it...is there anyway that I can write this into a
single file that they double click to execute and run? Also, If the
computer illiterate doesnt want to use it anymore, is there a way that
can I send a single file that would remove this ?


Reply





Michael Bauer
Oct 27, 4:00 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: Michael Bauer <[email protected]> - Find messages by this author
Date: Thu, 27 Oct 2005 10:00:55 +0200
Local: Thurs, Oct 27 2005 4:00 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Report Abuse

Am 26 Oct 2005 23:52:20 -0700 schrieb kaiser:


You could copy your project file (*.otm) from:
C:\Dokumente und Einstellungen\[User]\Anwendungsdaten\Microsoft\Outlook



to the other users computer. But note: Because OL can manage one
project
only, the other user would loose all existing functions (if there´s
any code
in his *.otm file already).


At least OL VBA isn´t for distributing. The recommended way is using
COM
Add-Ins, which you can´t unfortunately develop with VBA.


--
Viele Gruesse / Best regards
Michael Bauer - MVP Outlook



- Hide quoted text -
- Show quoted text -
Fantastic! It works perfectly! Thank you very very much for all your
help.
If I want to send this to someone who is very computer illiterate so
that they can use it...is there anyway that I can write this into a
single file that they double click to execute and run? Also, If the
computer illiterate doesnt want to use it anymore, is there a way that
can I send a single file that would remove this ?



Reply





kaiser
Oct 27, 4:06 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 27 Oct 2005 01:06:40 -0700
Local: Thurs, Oct 27 2005 4:06 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Thats fine...thakn you very much for all your help - a true gent


Reply





kaiser
Nov 6, 3:25 pm show options

Newsgroups: microsoft.public.outlook.program_vba
From: "kaiser" <[email protected]> - Find messages by this author

Date: 5 Nov 2005 23:25:28 -0800
Local: Sun, Nov 6 2005 3:25 pm
Subject: Re: Prompt email subject line when creating a new email
Reply | Reply to Author | Forward | Print | Individual Message | Show
original | Remove | Report Abuse

Hi
Can you give me one last bit of help with this please? i am trying to
send this to 5 other people (by copying the file to the users
directory). I can get it to run perfectly on their maching but have to

poen VBA on their pc and run the Application_Startup event (by
pressing F5)....closing and reopening outlook doesnt seem to work...is
there any way that i can get this to start by having them do something
more simple than open vba and starting it manually? Opening and
closing outlook would be perfect...but as I said, it doesnt seem to
work?
 
K

kaiser

I have resolved this issue by doing the following (incase anyone else
is interested)....I distrubuted the file via another piece of software
and to prevent the users having to open outlook to activate

Private Sub Application_Startup()
Set m_colInspectors = Application.Inspectors
End Sub

I created another macro that ran the above with the call
function....all the user had to do was to run the install prgoram and
then activate the macro by alt-F8 and selecting my macro that calls the
above
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top