Commands in a command button

T

TLC

I can put an command button on the form from Control Toolbox during design
mode.
but how can i sepecify an action for the button..(E.g. Calling a Script or
just to say hello)

I'm new and I'm using Outlook2003 with XP Pro.

Thanks!
 
S

Sue Mosher [MVP-Outlook]

Click the View Code button and write code like this:

Sub CommandButton1_Click()
MsgBox "Hello"
End Sub
 
T

TLC

I've put the "hello" code in as what you told and save the form.
but why when i double click the .oft file, the code in the command
button is not working... it only works if i choose Run This Forms from menu.

by the way, i know how to read a message attributes from program.
e.g. Reading messages and extracting attachments using API calls. but how
can i do that
if i want to those function inside a custom button on my forms,
let say extract the message body when i click on a custom button on my
outlook?

Thank in advance.
 
S

Sue Mosher [MVP-Outlook]

Unpublished forms, such as .oft files, don't run code. You must publish the
form first, using the Tools | Forms | Publish Form command, and then run the
published form.

API calls are not available to you in VBScript, which is what Outlook form
code uses.

The message body of the item where the form code is running is Item.Body.
Forms also support an intrinsic Application object.

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

TLC

The message body of the item where the form code is running is Item.Body.
Forms also support an intrinsic Application object.


Can you please show one simple example ?
Thanks!
 
S

Sue Mosher [MVP-Outlook]

Sub CommandButton1_Click()
MsgBox Item.Body
End Sub
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 

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