我的电子表格上有一些超链接,并使用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
End Sub
答案 0 :(得分:1)
您可以为每个ComboBox选项创建一个case语句,然后根据选择的情况(字符串)打开你的.pdf。