我试图找到并替换Outlook模板正文中的部分LINK文本。
Sub CreateFromTemplate()
last_week = InputBox("Enter date for last week (mm.dd-mm.dd)")
Dim body As String
' ELT
Dim ELTMail As Outlook.MailItem
Set ELTMail = Application.CreateItemFromTemplate("F:\AOtter\Outlook Templates\Metric Weeklies\ELT.oft")
body = myMessage.body
body = Replace(body,"07.27-08.02",last_week)
ELTMail.Display
End Sub
来自Outlook电子邮件的示例链接:
{LINK Excel.Sheet.12" \\ tlnfile \ users \ AOtter \ Metric Mondays \ Results \ 2015.xlsx" 07.27-08.02 !R4C9:R8C13 \ a \ f 4 \ h}
谁能告诉我我失踪了什么?我无法通过查找和替换来访问链接内部/我的操作是否错误访问?
答案 0 :(得分:0)
添加
Dim last_week as string
你打破了吗?
试
body = myMessage.body
debug.print body
debug.print Replace(body,"07.27-08.02","TRYTHIS")
body = Replace(body,"07.27-08.02","TRYTHIS")
debug.print body
正如您所期望的那样:
Sub Macro1()
Dim body As String
body = "{LINK Excel.Sheet.12 ""\\tlnfile\users\AOtter\Metric Mondays\Results\2015.xlsx"" 07.27-08.02!R4C9:R8C13 \a \f 4 \h}"
Debug.Print Replace(body, "07.27-08.02", "fred")
End Sub
答案 1 :(得分:0)
没关系,y'所有。
ELTMail.HTMLBody = Replace(ELTMail.HTMLBody, "07.27-08.02", last_week)
我有多傻。当然那就是它。对不起,麻烦!! AO