2015-10-20 78 views
1

當行號我有一個Excel電子表格,裏面發出的郵件使用VBA:發送Outlook電子郵件,並在郵件中添加超鏈接肚裏打開電子表格

Set OutApp = CreateObject("Outlook.Application") 
    Set OutMail = OutApp.CreateItem(0) 

    strbody = "This is email text, click the link <a href='C:\test.xlsm & Range("F" & ActiveCell.Row).Address'></a>" 

    On Error Resume Next 


    With OutMail 
     .To = "####" 
     .CC = "" 
     .BCC = "" 
     .Subject = "Sales Tracker: A New Task has been added to the tracker" 
     .HTMLBody = strbody & strbody2 & strbody3 & strbody4 
     .Send 'displays outlook email 
     'Application.SendKeys "%s" 'presses send as a send key 
    End With 
    On Error GoTo 0 

    Set OutMail = Nothing 
    Set OutApp = Nothing 

當用戶點擊電子郵件發送活動行內的特定單元格。

我包括在與超鏈接的電子郵件我的Excel電子表格,但現在我想能夠添加一些這會讓我包括該行的單元格引用,用戶點擊的超級鏈接時,他們發送了電子郵件。

這是超鏈接,當打開時會打開電子表格,並將用戶帶到鏈接指向的行並將其突出顯示。

請有人能告訴我如何做到這一點?在此先感謝

回答

0

我不確定是否有可能與超鏈接,最有可能不是。唯一讓我想到的是將Worksheet_Activate()事件添加到您附加的電子表格中,並指向您希望的範圍,但不包含超鏈接。

1

你缺少紙張的引用您的鏈接(即使我不知道,這將是足夠的),所以嘗試這樣的事:

href='[C:\test.xlsm]" & ActiveSheet.Name & "!" & Range("F" & ActiveCell.Row).Address & "'></a>" 

符合此格式:

href='[C:\test.xlsm]SheetName!A1' 

而且更重要的是,你忘了正確關閉引號,所以這裏有雲:

Set OutApp = CreateObject("Outlook.Application") 
Set OutMail = OutApp.CreateItem(0) 

strbody = "This is email text, click the link <a href='[C:\test.xlsm]" & _ 
      ActiveSheet.Name & "!" & Range("F" & ActiveCell.Row).Address & "'></a>" 

On Error Resume Next 


With OutMail 
    .To = "####" 
    .CC = "" 
    .BCC = "" 
    .Subject = "Sales Tracker: A New Task has been added to the tracker" 
    .HTMLBody = strbody & strbody2 & strbody3 & strbody4 
    .Send 'displays outlook email 
    'Application.SendKeys "%s" 'presses send as a send key 
End With 
On Error GoTo 0 

Set OutMail = Nothing 
Set OutApp = Nothing 
相關問題