I am trying to add a hyperlink to a cell to open a folder the code below makes the hyperlink in the proper cell and is when clicked redirects to the proper folder but it does not display the text provided it instead displays the folder name e.g. (:C:\Documents and Settings\abulle\Desktop\Python-Stuff\Spec-Load\Formatted\) instead of ‘Folder’
sheet.Hyperlinks.Add( Anchor = sheet.Cells(7,21), Address = "C:\\Python-Stuff\\Spec-Load\\Formatted\\" , TextToDisplay = "Folder")
I have a stopgap answer, a kludge. I don’t have time at the moment to find a better answer. If this was part of my day job I’d spend the time to find out what’s going on.
I’ve had the same issue (Excel shows the link address as the cell text instead of the
TextToDisplayvalue supplied onHyperlinks.Add())My code works under unit test when invoked by running the Python 2.7 interpreter – the value of the
'TextToDisplay'argument is displayed in the cell. The ‘production’ code (built usingpy2exe) displays the hyperlink. I’ll find out why some day (this is low background work.)Hyperlinks.Addreturns theHyperlinkobject it just added. The workaround is to examine theTextToDisplayproperty of that object – if it’s not what I want, I assign the correct value to it.