0

我的电子表格上有一些超链接,并使用 Select Case Target.TextToDisplay 跟随超链接。除了单元格 E25 中的一个超链接外,它们都可以正常工作。创建了超链接,但由于单元格的值是动态的(随着组合框的选择而变化),我无法设置特定的文本来查找和跟踪超链接。我创建了一个变量并尝试使用该值来跟踪超链接,但它不会。超链接应该打开一个 pdf 报告。

这是我写的,再次创建了超链接,但是单击它时不会打开报告。问题在于最后一个案例。随附的屏幕截图显示了超链接单元格。随着组合框值的变化,E25 中的值也会发生变化。该链接应该转到具有相同名称的 pdf 报告加上 .pdf在此处输入图像描述

Private Sub dsbPositionBoard_FollowHyperlink(Target As Microsoft.Office.Interop.Excel.Hyperlink) Handles Me.FollowHyperlink

'This procedure runs when any of the hyperlinked cells in the position dashboard are clicked
'The hyperlinks open the frmDefinition on the assigned defintion. The procedure calls
'the function. 

'The hyperlinked cells are assigned under the ThisWorkbook/Open event.

Dim definitionForm As New frmDefinitions

xlWB = CType(Globals.ThisWorkbook.Application.ActiveWorkbook, Excel.Workbook)
xlWSPOS = CType(xlWB.Sheets("positionBoard"), Excel.Worksheet)

Dim xlRng As Excel.Range = DirectCast(xlWSPOS.Range("E25"), Excel.Range)
Dim jobCodeReport As String = DirectCast(xlRng.Value.ToString, String)
Dim xlWBPath As String

xlWBPath = Globals.ThisWorkbook.Application.ActiveWorkbook.Path

Select Case Target.TextToDisplay

    Case "Exempt"
        definitionForm.tmr_out.Enabled = True
        sheetView.exemptDefinition()

    Case "Employee Pay Distribution for Ranges", "Low Third", "Upper Third"
        definitionForm.tmr_out.Enabled = True
        sheetView.lowerThirdDefinition()

    Case "Market Percentiles"
        definitionForm.tmr_out.Enabled = True
        sheetView.marketPercentileDefinition()

    Case "Min", "Mid", "Max", "Salary Range to Mkt"
        definitionForm.tmr_out.Enabled = True
        sheetView.payGradeWidthDefintion()

    Case "Total Cash Compensation Data"
        definitionForm.tmr_out.Enabled = True
        sheetView.totalCashCompDefition()

    Case "Compa-Ratio"
        definitionForm.tmr_out.Enabled = True
        sheetView.compaRatioDefinition()

    Case "Click here to build ranges"
        customRanges()

    Case "T-test Results", "Median Test Results"
        Globals.refCohortAnalysis.Select()

    Case jobCodeReport
        System.Diagnostics.Process.Start(xlWBPath & "\" & jobCodeReport & ".pdf")


End Select

结束子

4

1 回答 1

1

您可以为每个 ComboBox 选项创建一个案例语句,然后根据选择的案例(字符串)以这种方式打开您的 .pdf。

于 2013-08-21T17:20:34.193 回答