View Single Post
  #2   Report Post  
Posted to microsoft.public.excel.programming
Jim Cone Jim Cone is offline
external usenet poster
 
Posts: 3,290
Default Hyperlink Defaults

Dave,
I know of no way to preset the display in the Insert Hyperlinks box.
Somebody else may know how.
The following code achieves the same end by inserting a hyperlink
formula in the active cell instead of a hyperlink object.
You get the same result and hyperlink formulas use less memory.
--
Jim Cone
San Francisco, USA
http://www.realezsites.com/bus/primitivesoftware

Sub MakeEasyHyperlinks()
'Jim Cone - San Francisco, USA - November 2006
'Adds hyperlink formula in the active cell.
'The strNewPath variable specifies the path to the folder
'containing the file to be linked.
'Calls function "SomeplaceBetter"
'To make this work, user should add a custom button to a
'toolbar and assign this macro (MakeEasyHyperlinks) to it.

On Error GoTo BadPathToFollow
Dim strNewPath As String
Dim strOldPath As String
Dim varFilePath As Variant

strOldPath = Application.DefaultFilePath
strNewPath = "C:\Program Files\Microsoft Office\Office"

'Change to the new file path.
Call SomeplaceBetter(strNewPath)

'Displays box in which to select the file.
varFilePath = Application.GetOpenFilename(Title:="Select File to Hyperlink")
If varFilePath = False Then
Call SomeplaceBetter(strOldPath)
Exit Sub
End If
'Enters hyperlink formula in active cell.
ActiveCell.Formula = "=Hyperlink(""" & varFilePath & """)"

'Restores the original file path
Call SomeplaceBetter(strOldPath)

Exit Sub
BadPathToFollow:
MsgBox "Went down the wrong path. "
End Sub


Function SomeplaceBetter(ByRef strPath As String) As Byte
ChDrive strPath
ChDir strPath
End Function
'-------------------



"Dave B"
wrote in message
I am constantly adding hyperlinks to non-office files in a specific folder
other than the one the Excel workbook is in. Is there a way to set the
defaults of the Insert Hyperlink popup so that upon selecting a cell and
selecting Hyperlink a file window will popup with All Files in the Specific
Folder?
I appreciate any help you can offer.
Thanks Dave B