+ Reply to Thread
Results 1 to 3 of 3

Macro for setting hyperlinks

  1. #1
    Registered User
    Join Date
    07-09-2008
    Location
    Australia
    Posts
    2

    Cool Macro for setting hyperlinks

    Hi

    I have a column of numeric values. (e.g. 100, 120,132 etc.)

    I want each cell in the column to link to a corresponding file on the file system.

    The filenames begin with the numeric value in the cell (e.g. '100 info', '120 data', '132 report' etc.)

    All the files are in the same folder location, and I've set me htmlbase location to it.

    I would like to create a macro that creates a hyperlink for each cell in the column such that the cell with value '100' links to the filename that begins with the same value i.e. '100 info' from the above examples.

    I don't know what code i need for this (I am not very familiar with VB or programming excel modules) although I have written the psuedocode for it below:

    ' Get list of filenames at htmlbase location.
    ' For each filename
    ' if cell value is same as beginning of filename
    ' then set hyperlink for cell to that filename
    ' exit
    ' else do nothing

    Could someone help me out with this?
    thanks

  2. #2
    Registered User
    Join Date
    07-09-2008
    Location
    Melbourne
    Posts
    33
    I think that you will need to combine the following two functions but I cannot work out exactly how.

    With Application.FileSearch
    .NewSearch
    .LookIn = "C:\My Documents"
    .TextOrProperty = activecell.value
    .MatchTextExactly = True
    .FileType = msoFileTypeAllFiles
    End With

    ActiveSheet.Hyperlinks.Add Anchor:=Selection, Address:="Result.doc"

    Let me know if you have any sucess..


    edit

    Sub fun()
    Sep = Application.PathSeparator
    For Each chicken In Selection
    ActiveSheet.Hyperlinks.Add Anchor:=chicken, Address:=Dir(CurDir() & Sep & chicken.Value & "*.*")
    Next
    End Sub
    Last edited by flex; 07-10-2008 at 01:00 AM.

  3. #3
    Registered User
    Join Date
    07-09-2008
    Location
    Australia
    Posts
    2
    Actually I know very little about the VB API for Excel, so I'm not sure where to begin with adapting the code.

    Would it make sense for me to upload a zip of a test xls with some data and request someone else provide the macro?

+ 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