我有一个自定义表单,我想完全控制打开的appointmentItem,当用户点击按钮我希望项目和数据保存(我有),但我想要窗口关闭...
const olAppointmentItem = 9
Sub btn_create_Click()
MsgBox " wtf!!"
'get aplpication context
Dim myOutlook
Set myOutlook = CreateObject("Outlook.Application")
'get shell access
Dim objShell
Set objShell = CreateObject("Shell.Application")
'get the namespace for access to shipping folder
Dim myNameSpace
Set myNameSpace = myOutlook.GetNamespace("MAPI").GetDefaultFolder(9)
'get the location of the shipping folder
Dim myFolder
Set myFolder = myNameSpace.Parent
Set mySharedFolder= myNameSpace.Parent.Folders("Shipping")
' Create a new appointment.
Set olAppt = mySharedFolder.Items.Add
'declare vars to pull from the form
Set oPage = Item.GetInspector.ModifiedFormPages
Set ship_company = oPage("Shipping").Controls("tb_CompanyName")
Set ship_date = oPage("Shipping").Controls("tb_shipDate")
Set ship_address = oPage("Shipping").Controls("tb_address")
Set ship_freighter = oPage("Shipping").Controls("tb_freighter")
Set ship_truck_type = oPage("Shipping").Controls("tb_truckType")
'TODO : need to figure out way for bv numbers because of multiline
'split the date value so it plays nice
Dim temp
temp = ship_date.text
Dim realDate
realDate = split(ship_date," ",2)
' Setup other appointment information...
With olAppt
' .Start = #10/4/2014 9:00 PM#
.Start = realDate(1)
.Duration = 0
.Subject = "Meeting to discuss plans..."
.Body = "Meeting with fRANK to discuss plans."
.Location = "Home Office"
.ReminderMinutesBeforeStart = 0
.ReminderSet = false
.Save
End With
'Save and close Appointment...
olAppt.Close (olSave)
Set myOutlook = Nothing
MsgBox "Done!"
end Sub
我非常喜欢VBScript但是.close函数不起作用,我错过了什么?
答案 0 :(得分:0)
VBA中没有显示任何内容但
myOutlook.Quit
Set myOutlook = Nothing
如果已打开则应关闭Outlook。