从Excel中发送Outlook电子邮件,并在打开电子表格时添加到行号的电子邮件中的超链接

我有一个Excel电子表格,使用vba发送一封电子邮件:

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电子表格,但是现在我希望能够向超链接添加内容,这将允许我包含用户在发送电子邮件时所点击的行的单元格引用

这个想法是超链接打开时会打开电子表格,并将用户带到链接引用的行,并突出显示它。

请有人告诉我如何做到这一点? 提前致谢

你错过了链接中的工作表引用(即使我不确定这是否足够),所以尝试这样的事情:

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

以匹配这种格式:

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

而且更重要的是,你忘了正确地closures引号,所以在这里:

 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 

我不确定是否可以通过超链接来完成,很可能不是。 唯一让我想到的是将Worksheet_Activate()事件添加到您附加的电子表格中,并指向您希望的范围,但不包含超链接。