簡體   English   中英

Outlook 到 Excel 超鏈接問題

[英]Outlook to Excel hyperlink issue

希望你能幫助我理解我在這里做錯了什么。

作為 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 進行后期綁定,因此 Outlook 不了解什么是Selection

更改這些行

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"

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM