希望你能帮助我理解我在这里做错了什么。
作为 Outlook 宏的一部分,我希望使用指向文档的超链接来更新 Excel 中的单元格。
'~~> Excel variables
Dim oXLApp As Object, oXLwb As Object, oXLws As Object
'~~> Establish an EXCEL application object
On Error Resume Next
Set oXLApp = GetObject(, "Excel.Application")
'~~> If not found then create new instance
If Err.Number <> 0 Then
Set oXLApp = CreateObject("Excel.Application")
End If
Err.Clear
On Error GoTo 0
'~~> Show Excel
oXLApp.Visible = True
'~~> Open the relevant file
Set oXLwb = oXLApp.Workbooks.Open("V:\Dir\filename.xls")
'~~> Set the relevant output sheet. Change as applicable
Set oXLws = oXLwb.Sheets("Outstanding")
oXLws.Range("R11").Select
oXLws.Range("R11").Hyperlinks.Add Anchor:=Selection, Address:= _
"V:\Dir\" & emailsub & ".msg" _
, TextToDisplay:="Here"
由于某种原因它只是调试,代码在 Excel 中工作正常,所以我一定错过了一些东西,请帮忙!
干杯,多姆
最佳答案
由于您与 Excel 进行了后期绑定(bind),Outlook 无法理解什么是选择
更改这些行
oXLws.Range("R11").Select
oXLws.Range("R11").Hyperlinks.Add Anchor:=Selection, Address:= _
"V:\Dir\" & emailsub & ".msg", TextToDisplay:="Here"
至
oXLws.Range("R11").Hyperlinks.Add Anchor:=oXLws.Range("R11"), Address:= _
"V:\Dir\" & emailsub & ".msg", TextToDisplay:="Here"
关于excel - Outlook 到 Excel 的超链接问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/19300311/