Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Hyperlink screen tip causing workbook to need repairs

Tags:

excel

vba

I am using VBA to create hyperlinks to cells in different sheets in Excel and when I add a screen tip everything works fine until I close the workbook.

Upon reopening, Excel makes repairs and forces me to open read only. Getting rid of the screen tip solves the problem but having the screen tip is incredibly convenient.

Does anyone know what might cause this?

Hyperlinks.Add wb.Sheets("Summary").Cells(j, i + 2), "", "'" & i & "'!" & wb.Sheets(i + 1).Cells(3, col).Address, scrTip

Edit:

Here is the code I am using to create scrTip.

scrTip = ""

For indx = 0 To 4

      If TopCost(indx) <= 0 Then Exit For

      If indx > 0 Then scrTip = scrTip & vbCrLf
      scrTip = scrTip & strTopCost(indx) & " - " & Round(TopCost(indx))

Next indx

Array strTopCost contains descriptions that can have symbols like ",-,&,/, #, etc while the topcost array contains a number. The screen tip shows the location of the hyperlink when scrTip is empty.

like image 471
Hefrum Avatar asked Dec 08 '25 09:12

Hefrum


1 Answers

Please give the following a try:

wb.Sheets("Summary").Hyperlinks.Add _
    AnchorAnchor:=Cells(j, i + 2), _
    Address:="", _
    SubAddress:="'" & i & "'!" & wb.Sheets(i + 1).Cells(3, col).Address, _
    ScreenTip:=scrTip

Also, make sure to delete any existing hyperlinks prior to creating new ones:

Dim hyp As Hyperlink
For Each hyp In ThisWorkbook.Sheets("Summary").Hyperlinks
    hyp.Delete
Next hyp
like image 87
Ralph Avatar answered Dec 11 '25 00:12

Ralph



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!