LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Hyperlinks to =Hyperlinks formula - Challenging


Hi;
Wondered if someone would help me make this work, and/or simplify.
Trying to convert all inserted/hyperlinks automatically to '=Hyperlin
Formulas', using the existing hyperlink-VALUE (NOT the address whic
are scr... up (relative paths horror)).

Any chance of tweaking this code to make it fly ?
Also, what should I put in the function name's parentheses?
Thanks.



Function FunctionCreateHLFormula()

Option Explicit

Dim MyPath As String
Dim HL As Hyperlink
Dim sh As Worksheet
Dim Currfile As String
Dim CurrWb As Workbook
Dim xlink As String
Dim cell As Range


On error goto FuncFail:

'Change this path to where the workbooks are
MyPath = "C:\Temp\Temp4\"

'Find the first xls file in the directory
Currfile = Dir(MyPath & "*.xls")


'Do while there is at least one xls file
Do While Currfile < ""
'Open the file
Set CurrWb = Workbooks.Open(MyPath & Currfile)
'Cycle through the sheets
For Each sh In CurrWb.Worksheets
'Cycle through the hyperlinks on the sheet
For Each HL In sh.Hyperlinks
'
xlink = cell.Value
cell.HL.Delete
cell.Formula = "=HYPERLINK(""" & xlink & """,""" & xlink & """)

'Mostly to open docs, pics on network shares
Next HL
Next sh
'Close the workbook
CurrWb.Close False
'Find the next xls file
Currfile = Dir
Loop


Set CurrWb = Nothing
Set sh = Nothing
Set HL = Nothing


End Sub


FuncFail:
MyPath=CvErr(xlErrValue)
HL=CvErr(xlErrValue)
sh=CvErr(xlErrValue)
Currfile=CvErr(xlErrValue)
Currwb=CvErr(xlErrValue)
xlink=CvErr(xlErrValue)
cell.Formula=CvErr(xlErrValue)
cell.value=CvErr(xlErrValue)

End Functio

--
Electro91
-----------------------------------------------------------------------
Electro911's Profile: http://www.excelforum.com/member.php...fo&userid=3194
View this thread: http://www.excelforum.com/showthread.php?threadid=51708

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Hyperlinks: Hyperlinks change on copy/paste? Rick S. Excel Worksheet Functions 0 November 13th 07 08:19 PM
Update 2000 Excel hyperlinks to 2003 hyperlinks lonv155 Excel Worksheet Functions 4 October 25th 07 05:51 AM
How toi turn-off hyperlinks [excel]? Email hyperlinks pop up ! jacob735 Excel Discussion (Misc queries) 1 June 22nd 07 12:57 AM
Excel Hyperlinks- cell content v. hyperlinks herpetafauna Excel Discussion (Misc queries) 2 May 23rd 06 04:39 AM
Challenging Formula in VB Bruce Roberson[_2_] Excel Programming 7 January 21st 04 12:28 PM


All times are GMT +1. The time now is 01:27 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"