PC Review


Reply
Thread Tools Rate Thread

CommandButton to send a form

 
 
tmreyes
Guest
Posts: n/a
 
      5th Feb 2009
I want to add a command button to a form that will send or forward the form
contents after it has been filled out to a predetermined PDL and the person
that sent the form orginally. I am new to VB so looking for code examples.
thanks in advance.
--
tmreyes
 
Reply With Quote
 
 
 
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      6th Feb 2009
For information on all that to get you started look at www.outlookcode.com.
There's information there on Outlook forms, setting up buttons and working
with Outlook VBA macro code and COM addins.

For future reference please post the Outlook version you are using so the
appropriate answers can be provided.

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"tmreyes" <(E-Mail Removed)> wrote in message
news:57DE4443-32A1-46F7-9AFC-(E-Mail Removed)...
>I want to add a command button to a form that will send or forward the form
> contents after it has been filled out to a predetermined PDL and the
> person
> that sent the form orginally. I am new to VB so looking for code examples.
> thanks in advance.
> --
> tmreyes


 
Reply With Quote
 
tmreyes
Guest
Posts: n/a
 
      11th Feb 2009
Ken -
I created the form and published it to a personal folder. i have a command
button on the form. when i run the form and click the button the code behind
the button does not work but when i run the code in VB editor it works.
here is the code:
Sub CommandButton1_Click ()
Dim myolApp As Outlook.Application
Dim myinspector As Outlook.Inspector
Dim myItem As Outlook.MailItem
Dim myattachments As Outlook.Attachments
Set myolApp = CreateObject("Outlook.Application")
Set myinspector = myolApp.ActiveInspector
If Not TypeName(myinspector) = "Nothing" Then
Set myItem = myinspector.CurrentItem.Forward
myItem.Recipients.Add "Reyes, Mark M [IT]"
myItem.Send
Else
MsgBox "There is no active inspector."
End If
End Sub

any suggestions? thanks in advance
--
tmreyes


"Ken Slovak - [MVP - Outlook]" wrote:

> For information on all that to get you started look at www.outlookcode.com.
> There's information there on Outlook forms, setting up buttons and working
> with Outlook VBA macro code and COM addins.
>
> For future reference please post the Outlook version you are using so the
> appropriate answers can be provided.
>
> --
> Ken Slovak
> [MVP - Outlook]
> http://www.slovaktech.com
> Author: Professional Programming Outlook 2007.
> Reminder Manager, Extended Reminders, Attachment Options.
> http://www.slovaktech.com/products.htm
>
>
> "tmreyes" <(E-Mail Removed)> wrote in message
> news:57DE4443-32A1-46F7-9AFC-(E-Mail Removed)...
> >I want to add a command button to a form that will send or forward the form
> > contents after it has been filled out to a predetermined PDL and the
> > person
> > that sent the form orginally. I am new to VB so looking for code examples.
> > thanks in advance.
> > --
> > tmreyes

>
>

 
Reply With Quote
 
Ken Slovak - [MVP - Outlook]
Guest
Posts: n/a
 
      11th Feb 2009
You are trying to use VBA type code with VBScript, which won't work. VBS has
no As clauses, all variables are Variants. So comment out all those As
clauses. Never create an Outlook.Application object in form code, use the
intrinsic Application object, which is trusted (references to the item for
the form should be Item, also intrinsic and trusted).

--
Ken Slovak
[MVP - Outlook]
http://www.slovaktech.com
Author: Professional Programming Outlook 2007.
Reminder Manager, Extended Reminders, Attachment Options.
http://www.slovaktech.com/products.htm


"tmreyes" <(E-Mail Removed)> wrote in message
news:19C90E5D-A332-45ED-B932-(E-Mail Removed)...
> Ken -
> I created the form and published it to a personal folder. i have a command
> button on the form. when i run the form and click the button the code
> behind
> the button does not work but when i run the code in VB editor it works.
> here is the code:
> Sub CommandButton1_Click ()
> Dim myolApp As Outlook.Application
> Dim myinspector As Outlook.Inspector
> Dim myItem As Outlook.MailItem
> Dim myattachments As Outlook.Attachments
> Set myolApp = CreateObject("Outlook.Application")
> Set myinspector = myolApp.ActiveInspector
> If Not TypeName(myinspector) = "Nothing" Then
> Set myItem = myinspector.CurrentItem.Forward
> myItem.Recipients.Add "Reyes, Mark M [IT]"
> myItem.Send
> Else
> MsgBox "There is no active inspector."
> End If
> End Sub
>
> any suggestions? thanks in advance
> --
> tmreyes


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Word: Need form's CommandButton to open another doc. HOW? Amanda Ennis Microsoft Word Document Management 1 12th Mar 2010 01:17 AM
Problem with form that thinks it a commandbutton (possibly?) Vlad Microsoft Access Form Coding 3 23rd Feb 2006 09:48 AM
How do set up a commandbutton on a customer form to open a web pag =?Utf-8?B?U2VhbiBNY0Nsb3NrZXk=?= Microsoft Outlook Form Programming 3 1st Feb 2006 10:16 PM
Open contact from form with CommandButton Simon Microsoft Outlook Form Programming 0 10th Sep 2004 08:05 AM
CommandButton click won't fire on form? Dave Microsoft Outlook Form Programming 5 31st Aug 2004 03:38 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 05:05 PM.