0
我正在嘗試創建一個爲特定(共享)日曆創建三個Outlook約會的宏。這些活動將始終是全天活動。最後,我希望能夠將宏與一個按鈕相關聯,以便當按鈕被按下時,當前行的日期被添加到日曆中。所有三個日期將在電子表格的同一行中。從Excel電子表格中創建Outlook約會到特定日曆
這是我到目前爲止(我知道它不是很多),請讓我知道我需要補充什麼。我對VBA仍然很陌生。下面的代碼成功創建約會,但由於某種原因,for循環無法正常工作。唯一創建的事件是最後一個日期。
Sub Makeapt()
Set myOutlook = CreateObject("Outlook.Application")
Set myApt = myOutlook.createitem(1)
Dim i As Integer
For i = 3 To 5
myApt.Subject = Cells(ActiveCell.Row, 1).Value
myApt.Start = Cells(ActiveCell.Row, i).Value
myApt.Save
Next i
End Sub
沒關係,我解決了這個問題。 Appt仍然會使用默認日曆,但實際上它更可取。
Sub Makeapt()
Dim warning
warning = MsgBox("You are about to create Outlook appointments for subject #" & Cells(ActiveCell.Row, 3) & ". Is that right?", vbOKCancel)
If warning = vbCancel Then Exit Sub
Set myOutlook = CreateObject("Outlook.Application")
Set ID = Cells(ActiveCell.Row, 3)
Dim i As Integer
For i = 7 To 9
Set myApt = myOutlook.createitem(1)
myApt.Subject = "Subject #" & ID
myApt.Start = Cells(ActiveCell.Row, i).Value
myApt.Save
Next i
末次