Did you publish the form to your Personal Forms library? Code runs only on
published forms.
--
Sue Mosher, Outlook MVP
Author of Microsoft Outlook 2007 Programming:
Jumpstart for Power Users and Administrators
http://www.outlookcode.com/article.aspx?id=54
"Stefan" wrote:
> Hi all!
>
> I am very new in designing Outlook Forms. However I designed my first form
> including a CommandButton which should paste a text into a TextBox (I
> programmed this function in the VBScript Editor). If I am working in the
> Developer Mode and click on "Run This Form", the function works properly.
> However if I open the form and directly click on the CommandButton (without
> entering the Developer Mode and clicking Run This Form") or if I send the
> Form, it doesn`t work anymore.
> This is the Code I use:
>
> Sub CommandButton2_Click()
> Dim RequestID
> Dim Tower
> Dim Subject
> Dim Datum
>
> 'get control items
> Set RequestID = Item.GetInspector.ModifiedFormPages.Item("Request for
> Change").Controls("RequestID")
> Set Tower = Item.GetInspector.ModifiedFormPages.Item("Request for
> Change").Controls("Tower")
> Set Subject = Item.GetInspector.ModifiedFormPages.Item("Request for
> Change").Controls("Subject")
> Set Datum = Item.GetInspector.ModifiedFormPages.Item("Request for
> Change").Controls("Datum")
>
> RequestID.Value = "DE1-HBM02-IMS-" & Year(Date) & Month(Date) & Day(Date) &
> Hour(Time) & Minute(Time)
> Subject.Value = "Request for Change " & RequestID.Value & " " & "<" &
> Tower.Value & ">"
> Datum.Value = Day(Date) & "." & Month(Date) & "." & Year(Date)
> End Sub
>
> How can I make the CommandButton work ALWAYS????