Microsoft Outlook 365 ProPlus -Macro无法正常工作 [英] Microsoft Outlook 365 ProPlus -Macro not working
问题描述
我收到此宏来检测会议何时添加到我的日历中,并提供阻止其任何一方的旅行时间的机会。 (创建一个从1:15到2:15运行的会议,然后脚本将从1:00 - 1:15创建约会
I received this macro to detect when a meeting is added to my calendar and give an opportunity to block-off travel time on either side of it. (create a meeting to run from 1:15 to 2:15, then the script would create an appointment
from 1:00 – 1:15 for travel to the meeting and another from 2:15 – 2:30 to return from the meeting. 然而,我只是无知(所以不是开发人员)不理解为什么第一个语句会收到语法错误。 However, I am just ignorant enough (so not a developer) to not understand why the very first statement receives a syntax error. 你能帮忙吗?可能有一个更简单的宏? 据我所知,我需要删除第16和第42行才能使其适用于约会。 但是,我希望它适用于会议和约会。而且,我想要 Can you help? Maybe there is a simpler macro? As I understand it, I need to remove lines 16 and 42 in order for this to work for appointments. However, I want it to work for both meetings and appointment. Also, I want to
alter it to allow me to choose the amount of time before/after a meeting, as sometimes I need 45 minutes of travel each way. 我在使用Windows 7专业版的网络上使用Microsoft Outlook 365 ProPlus I am using Microsoft Outlook 365 ProPlus on a network using Windows 7 Professional 这是我给出的:(我不是问ori ginator,因为他们没有回复我的后续问题) Here is what I was given: (I am not asking the originator, as they did not respond to my follow up questions) 有人可以帮我这个吗? 1:Dim WithEvents olkCalendar作为Outlook.Items 1:Dim WithEvents olkCalendar As Outlook.Items 您可以替换以下代码行: You can replace the following line of code: 到下面这个:
这篇关于Microsoft Outlook 365 ProPlus -Macro无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
,以便前往会议,另一个从2:15 - 2: 30从会议中返回。
更改它以允许我选择会议之前/之后的时间,因为有时我需要单程旅行45分钟。
2:
3 :Private Sub Application_Quit()
4: 设置olkCalendar = Nothing
5:End Sub
6:
7:Private Sub Application_Startup()
8: 设置olkCalendar = Session.GetDefaultFolder(olFolderCalendar).Items
9:End Sub
10:
11:Private Sub olkCalendar_ItemAdd(ByVal Item As Object)
12: Const SCRIPT_NAME ="安排旅行时间"
13: Dim olkTravel1作为Outlook.AppointmentItem,_
14: olkTravel2作为Outlook.AppointmentItem,_
15: intMinutes As Integer
16: 如果Item.MeetingStatus = olMeeting那么
17: 如果MSGBOX("你需要安排出行时间,本次会议" ;, vbQuestion + vbYesNo,SCRIPT_NAME?)= vbYes然后
18:    &NBSP ;       intMinutes =的InputBox(QUOT;多少分钟各方式" ;, SCRIPT_NAME,15?)
19分配:            如果intMinutes> 0然后
20: 设置olkTravel1 = Application.CreateItem(olAppointmentItem)
21:                与olkTravel1
22:                 &NBSP ;  "根据需要编辑主题"
23:      .Subject ="前往会议:" &安培; Item.Subject
24:                     。开始=使用DateAdd(QUOT; N" ;, intMinutes * -1,Item.Start)
25:                     .END = Item.Start
26:               &NBSP ;    .Categories = Item.Categories
27:               &NBSP ;    .BusyStatus = olBusy
28:                &NBSP ;   .Save
29: 结束与
30: 设置olkTravel2 = Application.CreateItem(olAppointmentItem)
31:                与olkTravel2
32:                 &NBSP ;  "根据需要编辑主题"
33:      .Subject ="从会议出发:" &安培; Item.Subject
34:                     。开始= Item.End
35:               &NBSP ;    .END =使用DateAdd(QUOT; N" ;, intMinutes,Item.End)
36:          &NBSP ;         .Categories = Item.Categories
37:               &NBSP ;    .BusyStatus = olBusy
38:                &NBSP ;   .Save
39: 结束与
40: 结束如果
41: 结束如果
42: 结束如果
43: 设置olkTravel1 = Nothing
44: 设置olkTravel2 = Nothing
45:End Sub
2:
3:Private Sub Application_Quit()
4: Set olkCalendar = Nothing
5:End Sub
6:
7:Private Sub Application_Startup()
8: Set olkCalendar = Session.GetDefaultFolder(olFolderCalendar).Items
9:End Sub
10:
11:Private Sub olkCalendar_ItemAdd(ByVal Item As Object)
12: Const SCRIPT_NAME = "Schedule Travel Time"
13: Dim olkTravel1 As Outlook.AppointmentItem, _
14: olkTravel2 As Outlook.AppointmentItem, _
15: intMinutes As Integer
16: If Item.MeetingStatus = olMeeting Then
17: If msgbox("Do you need to schedule travel time for this meeting?", vbQuestion + vbYesNo, SCRIPT_NAME) = vbYes Then
18: intMinutes = InputBox("How many minutes each way?", SCRIPT_NAME, 15)
19: If intMinutes > 0 Then
20: Set olkTravel1 = Application.CreateItem(olAppointmentItem)
21: With olkTravel1
22: 'Edit the subject as desired'
23: .Subject = "Travel to Meeting: " & Item.Subject
24: .Start = DateAdd("n", intMinutes * -1, Item.Start)
25: .End = Item.Start
26: .Categories = Item.Categories
27: .BusyStatus = olBusy
28: .Save
29: End With
30: Set olkTravel2 = Application.CreateItem(olAppointmentItem)
31: With olkTravel2
32: 'Edit the subject as desired'
33: .Subject = "Travel from Meeting: " & Item.Subject
34: .Start = Item.End
35: .End = DateAdd("n", intMinutes, Item.End)
36: .Categories = Item.Categories
37: .BusyStatus = olBusy
38: .Save
39: End With
40: End If
41: End If
42: End If
43: Set olkTravel1 = Nothing
44: Set olkTravel2 = Nothing
45:End Sub推荐答案
If Item.MeetingStatus = olMeeting Then
If Item.Class = olAppointment Then
您可以找到
入门使用Outlook 2010中的VBA 文章很有帮助。
You may find the
Getting Started with VBA in Outlook 2010 article helpful.