CommandButton click won't fire on form?

D

Dave

Hi,

I have a custom outlook 2002 form with a CommandButton1.

In the "View Code" option I added the following and
selected "Run this form". When the form shows up in my
inbox the click event won't fire.

Sub CommandButton1_Click()
MsgBox "Hello"
End Sub

Eventually I want this to send an email but I wanted to
test it first...

Sub CommandButton2_Click()
Dim Outlook
Set Outlook = CreateObject("Outlook.Application")
Dim Email
Email = Outlook.CreateItem(olMailItem)

With Email
.Subject = "test.."
.Body = "body text..."
.To = "(e-mail address removed)"
.Send
End With

Outlook.Quit
Set Outlook = Nothing
End Sub
 
S

Sue Mosher [MVP-Outlook]

If the form runs code when you use Run This Form in design mode, but doesn't
run code after you have sent or saved an item using the form, you probably
have done something to "one-off" the form. Outlook 2003, Outlook 2002,
Outlook 2000 SP2 and Outlook 2000 or 98 with the Email Security Update will
not run code on one-off forms; see http://www.outlookcode.com/d/secforms.htm
for more information on this issue.

To ensure that a form does not one-off:

-- Make sure the "Send form definition with item" box on the (Properties)
tab of the form is *not* checked. [1]

-- For in-house corporate use with Exchange Server, publish the form to the
Organization Forms library or a public folder's forms library, as
appropriate for your application.

-- For collaboration via the Internet, publish your form to your Personal
Forms library. Save it as an .oft file and send it to other people who need
to use it with instructions to publish it with the same form name that you
used.

Many other things can cause one-off forms. If the above steps don't work on
a new item created with your form, see
http://www.slipstick.com/dev/formpub.htm#oneoff for other possible causes.

[1] Whenever you publish a message form, Outlook will suggest that you may
want to check the "Send form definition with item" box to ensure that the
recipient will have the form, especially if you're sending to someone via
the Internet. In the current Outlook security environment, this suggestion
is obsolete. Ignore it unless your form has no code behind it.

Also note that you do not need to create an Outlook.Application object. Form
code supports an intrinsic Application object.
 
S

Sue Mosher [MVP-Outlook]

If you cannot publish to Org Forms and you need code to run, you have only
one option -- have each user publish the message form to their own Personal
Forms library.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Dave said:
I forgot to add this is in-house (intranet) and we were getting some push
back publishing to Organizational lib. so I don't know what my options
are....

Dave said:
Sue,

Thanks. One follow-up though, I got the script to run when I UN-check
the
"Send form definition" option. But if I cc the form to my team member,
she
doesn't see the "Read Page" (survey form) I want users to fill out. Only
I
see it. She just sees the "Compose Page".

But, if check ON the "Send form definition", and cc her again, she gets
the
survey form but then the CommandButton's script doesn't work.

BTW, I'm publishing this to my personal forms libraray. Is my only
option
to publish to the Organizational forms lib? I don't get what is
happening.

Thanks again. Dave

Sue Mosher said:
If the form runs code when you use Run This Form in design mode, but
doesn't
run code after you have sent or saved an item using the form, you
probably
have done something to "one-off" the form. Outlook 2003, Outlook 2002,
Outlook 2000 SP2 and Outlook 2000 or 98 with the Email Security Update
will
not run code on one-off forms; see
http://www.outlookcode.com/d/secforms.htm
for more information on this issue.

To ensure that a form does not one-off:

-- Make sure the "Send form definition with item" box on the
(Properties)
tab of the form is *not* checked. [1]

-- For in-house corporate use with Exchange Server, publish the form to
the
Organization Forms library or a public folder's forms library, as
appropriate for your application.

-- For collaboration via the Internet, publish your form to your
Personal
Forms library. Save it as an .oft file and send it to other people who
need
to use it with instructions to publish it with the same form name that
you
used.

Many other things can cause one-off forms. If the above steps don't
work on
a new item created with your form, see
http://www.slipstick.com/dev/formpub.htm#oneoff for other possible
causes.

[1] Whenever you publish a message form, Outlook will suggest that you
may
want to check the "Send form definition with item" box to ensure that
the
recipient will have the form, especially if you're sending to someone
via
the Internet. In the current Outlook security environment, this
suggestion
is obsolete. Ignore it unless your form has no code behind it.


Hi,

I have a custom outlook 2002 form with a CommandButton1.

In the "View Code" option I added the following and
selected "Run this form". When the form shows up in my
inbox the click event won't fire.

Sub CommandButton1_Click()
MsgBox "Hello"
End Sub

Eventually I want this to send an email but I wanted to
test it first...

Sub CommandButton2_Click()
Dim Outlook
Set Outlook = CreateObject("Outlook.Application")
Dim Email
Email = Outlook.CreateItem(olMailItem)

With Email
.Subject = "test.."
.Body = "body text..."
.To = "(e-mail address removed)"
.Send
End With

Outlook.Quit
Set Outlook = Nothing
End Sub
 
S

Sue Mosher [MVP-Outlook]

No. Think about it: How would Outlook know to look in that particular public
folder for a message form?

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
G

Guest

Sorry, I guess I don't know. Can I just tell the user to look in a public
folder for the survey once I publish it there? This is all new to me and I'm
trying to figure out a method that will work.

In our company we are not allowed to have forms published to the Org.
Folder. I just wanted to know if a Public Folder will be a better solution
than having users manually publish the survey form to their personal forms
library.
I guess I want to fully understand this first since I have to submit a
formal request to get this public folder created.

In my book, having the users do less is always a better solution to
eliminate support issues.

Thanks, Dave
 
S

Sue Mosher [MVP-Outlook]

Can I just tell the user to look in a public
folder for the survey once I publish it there?

That might work -- if you also have the survey form published in the Inbox
or Personal Forms library of the people who will be reading the survey
results.
In our company we are not allowed to have forms published to the Org.
Folder. I just wanted to know if a Public Folder will be a better
solution
than having users manually publish the survey form to their personal forms
library.
I guess I want to fully understand this first since I have to submit a
formal request to get this public folder created.

You might want to read up on form library and cache issues at
http://www.outlookcode.com/d/formpub.htm and
http://www.outlookcode.com/d/formscache.htm
 

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