0
我一直在試圖創建一個從Excel選擇中獲取一些信息並在Outlook上創建新任務的子。任務的主體應該包含來自第一個單元格的註釋(它已經完成),但在我想粘貼範圍之前,先在Excel中查看,然後是評論,然後是範圍。將格式化的Excel範圍粘貼到Outlook任務中
這裏是我的代碼:
Sub CreateReminder()
Dim olApp As Object
Dim olRem As Object
Dim myRange As Range
Dim contact As String
Dim company As String
Dim city As String
Dim state As String
Dim cmt As comment
Dim comment As String
Dim strdate As Date
Dim remdate As Date
Set olApp = CreateObject("Outlook.Application")
Set olRem = olApp.CreateItem(3)
Set myRange = Selection
If ActiveCell.comment Is Nothing Then
Exit Sub
Else
Set cmt = ActiveCell.comment
End If
company = myRange.Columns(1).Text
contact = myRange.Columns(2).Text
If InStr(contact, "/") <> 0 Then
contact = Left(contact, InStr(contact, "/") - 1)
End If
city = myRange.Columns(7).Text
state = myRange.Columns(8).Text
myRange.Copy
comment = cmt.Text
strdate = Date
remdate = Format(Now)
rangeaddress = myRange.Address
wrksheetname = ActiveSheet.Name
With olRem
.Subject = "Call " & contact & " - " & company & " - " & city & ", " & state
.display
SendKeys "{TAB 9}"
SendKeys "^{v}"
.body = Chr(10) & comment & Chr(10)
'.startdate = strdate
'.remindertime = remdate
'.reminderset = True
'.showcategoriesdialog
End With
Set olApp = Nothing
Set olRem = Nothing
End Sub
正如你所看到的,我能夠使用的SendKeys方法進行粘貼,但它是那種一個黑客,而不是......複雜。我相信還有另外一種方式來實現它,有什麼想法?
我發現代碼粘貼爲HTML到電子郵件,但據我所知,郵件項目允許HTML,但不是任務項目。
感謝您的回答。不幸的是,在閱讀和嘗試之後,我無法使其工作。我想我沒有足夠的知識。謝謝(你的)信息。 –
標記爲已解決,因爲嘗試數月後,這是解決方案。非常感謝。 –