To set one field with the value of another :
Sub CommandButton9_Click
Set TextBox9 = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox9")
TextBox9.Text = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1").Text
end sub
To create a new appointment do this :
Dim objOL 'As Outlook.Application
Dim objAppt 'As Outlook.AppointmentItem
Const olAppointmentItem = 1
Const olMeeting = 1
Const olFree = 0
Set objOL = CreateObject("Outlook.Application")
Set objAppt = objOL.CreateItem(olAppointmentItem)
objAppt.Subject = "My Test Appointment"
objAppt.Start = #8/19/03 3:50:00 PM#
objAppt.Duration = 1
objAppt.Location = "Followup"
objAppt.Body = "Test Verbiage"
objAppt.ReminderMinutesBeforeStart = 1
objAppt.BusyStatus = olFree
objAppt.Save()
Set objAppt = Nothing
Set objOL = Nothing
End Sub
( copied from http://www.pcreview.co.uk/forums/create-calendar-appointment-vbscript-command-button-t1836976.html )
but to display it before sending use objAppt.Display() ( handy for debugging )
To display the current user:
Sub DisplayCurrentUser()
Dim myNamespace 'As Outlook.NameSpace
Set myNameSpace = Application.GetNameSpace("MAPI")
Set TextBox4 = myNameSpace.CurrentUser
MsgBox myNameSpace.CurrentUser
End Sub
Also handy in there for debugging is the MsgBox.
when creating a new appointment though using the already filled in start and end on the screen
you cannot just do this :
With objAppt
.Subject = "My Test Appointment"
.Start = Item.GetInspector.ModifiedFormPages("P.2").Controls("TextBox1").Text
( BTW the start field is called TextBox1 ), you do that you get TypeMismatch: Cannot coerce parameter value. OutLook cannot translate your string :
So what you have to do is substring it to get just the day/month/year eg
With objAppt
.Subject = "My Test Appointment"
.Start = Mid(TextBox9, 5, 10)
No comments:
Post a Comment