+ Reply to Thread
Results 1 to 7 of 7

Inserting Hyperlink in Excel 97 Macro

  1. #1
    Chris Hankin
    Guest

    Inserting Hyperlink in Excel 97 Macro

    Hi, I'm hoping please that someone could advise on how I can do the
    following:

    When a use clicks in Column I of my workbook named Queries, I want Excel to
    automatically do the following:

    This is what I now do manually:

    Click on Insert
    Click on Hyperlink
    Click on Browse (the Browse button adjacent to the drop-down box named Link
    To File or URL
    Select the following drive and directory: P:\DNSDC\LSA\QUERIES\EMAILS SENT\
    The tick box Use Relative Path For Hyperlink is checked

    So basically when a user clicks in Column I, I want Excel to automatically
    show the Insert Hyperlink Window
    with the above-mention drive and directory pre-selected so that the user
    only needs to select the .EML file and click on the OK button.

    Any help would be greatly appreciated.

    Kind regards,

    Chris.




  2. #2
    Mike Fogleman
    Guest

    Re: Inserting Hyperlink in Excel 97 Macro

    This should get you real close to what you want. Put this code in the sheet
    module of the sheet that you want the hyperlinks on.

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim fileToOpen As String
    Dim MyPath As String
    Dim SaveDriveDir As String
    If Not Application.Intersect(Range("I1:I65000"), Target) Is Nothing Then
    SaveDriveDir = CurDir
    MyPath = "P:\DNSDC\LSA\QUERIES\EMAILS SENT\"
    ChDrive MyPath
    ChDir MyPath

    fileToOpen = Application _
    .GetOpenFilename("Email Files (*.eml), *.eml")
    If fileToOpen = "False" Then Exit Sub
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=fileToOpen

    ChDrive SaveDriveDir
    ChDir SaveDriveDir
    Else: Exit Sub
    End If
    End Sub

    Mike F

    "Chris Hankin" <[email protected]> wrote in message
    news:[email protected]...
    > Hi, I'm hoping please that someone could advise on how I can do the
    > following:
    >
    > When a use clicks in Column I of my workbook named Queries, I want Excel

    to
    > automatically do the following:
    >
    > This is what I now do manually:
    >
    > Click on Insert
    > Click on Hyperlink
    > Click on Browse (the Browse button adjacent to the drop-down box named

    Link
    > To File or URL
    > Select the following drive and directory: P:\DNSDC\LSA\QUERIES\EMAILS

    SENT\
    > The tick box Use Relative Path For Hyperlink is checked
    >
    > So basically when a user clicks in Column I, I want Excel to automatically
    > show the Insert Hyperlink Window
    > with the above-mention drive and directory pre-selected so that the user
    > only needs to select the .EML file and click on the OK button.
    >
    > Any help would be greatly appreciated.
    >
    > Kind regards,
    >
    > Chris.
    >
    >
    >




  3. #3
    Chris Hankin
    Guest

    Re: Inserting Hyperlink in Excel 97 Macro





    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

  4. #4
    Chris Hankin
    Guest

    Re: Inserting Hyperlink in Excel 97 Macro

    Hello Mike,

    Thankyou very much for all you excellent help - the macro worked very
    well - except that it opens an Open Window instead of a Link to File
    Window.

    Is there any chance please that you might be able to modify you macro so
    that the Link to File Window opens up?

    Again thanks for your help - much appreciated.

    Kind regards,

    Chris.

    Live Long and Prosper

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

  5. #5
    Mike
    Guest

    Re: Inserting Hyperlink in Excel 97 Macro

    The browser window is the same, only the Title at the top is different. Here
    is the code to change the Title from "Open" to "Link to File".

    Private Sub Worksheet_SelectionChange(ByVal Target As Range)
    Dim fileToOpen As String
    Dim MyPath As String
    Dim SaveDriveDir As String
    If Not Application.Intersect(Range("I1:I65000"), Target) Is Nothing
    Then
    SaveDriveDir = CurDir
    MyPath = "P:\DNSDC\LSA\QUERIES\EMAILS SENT\"
    ChDrive MyPath
    ChDir MyPath

    fileToOpen = Application _
    .GetOpenFilename("Email Files (*.eml), *.eml", , "Link to File")
    If fileToOpen = "False" Then Exit Sub
    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:=fileToOpen

    ChDrive SaveDriveDir
    ChDir SaveDriveDir
    Else: Exit Sub
    End If
    End Sub


    Mike F


    Chris Hankin <[email protected]> wrote in message
    news:[email protected]...
    > Hello Mike,
    >
    > Thankyou very much for all you excellent help - the macro worked very
    > well - except that it opens an Open Window instead of a Link to File
    > Window.
    >
    > Is there any chance please that you might be able to modify you macro so
    > that the Link to File Window opens up?
    >
    > Again thanks for your help - much appreciated.
    >
    > Kind regards,
    >
    > Chris.
    >
    > Live Long and Prosper
    >
    > *** Sent via Developersdex http://www.developersdex.com ***
    > Don't just participate in USENET...get rewarded for it!




  6. #6
    Chris Hankin
    Guest

    Re: Inserting Hyperlink in Excel 97 Macro

    Thanks Mike - very much appreciated - cheers Chris.

    Live Long and Prosper

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

  7. #7
    Chris Hankin
    Guest

    Re: Inserting Hyperlink in Excel 97 Macro

    Thanks Mike - very much appreciated - cheers Chris.

    Live Long and Prosper

    *** Sent via Developersdex http://www.developersdex.com ***
    Don't just participate in USENET...get rewarded for it!

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1