Hyperlink walkthrough

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • jodyblau

    #1

    Hyperlink walkthrough

    I am trying to go through a list of files in a folder and then add a
    hyperlink to each one in a table.

    I am having a difficult time figuring out how to add that link into the
    table and do it in such a way that the entire path isn't displayed in
    the record, just the document name (just like I can make it look if I
    add the hyperlink by hand and then edit it using the dialog.)

    I have tried figuring it out using this article: (but I still don't get
    it)
    http://msdn.microsoft.com/archive/de...plications.asp

    Could someone kindly walk me through how to get from having a String
    with my file path stored in it, to adding it to my table, such that the
    link only displays the document name and not the full path?

    Thank you,

    Jody Blau

  • Terry Kreft

    #2
    Re: Hyperlink walkthrough

    It would be easier to makit specific for you if we knew your table tructure
    but here's an example which will hopefully make som sense.

    The table structure I used or this example was
    tlHyperLink
    ---------------
    Name DataType
    ID AutoNumber
    File Hyperlink

    The following actually adds the value to th table:-

    Sub AddHyperLink( _
    Tablename As String, _
    FieldName As String, _
    Hyperlink As String, _
    DisplayText As String _
    )
    Dim db As DAO.Database
    Dim strValue As String
    Dim strSQl As String

    Const ELEMENT_SEP = "#"

    If Len(DisplayText ) < 1 Then
    DisplayText = Hyperlink
    End If

    strValue = DisplayText & ELEMENT_SEP & Hyperlink & ELEMENT_SEP

    strValue = Replace(strValu e, "'", "''", Compare:=vbText Compare)

    strSQl = "INSERT INTO [" & Tablename & "] ([" _
    & FieldName & "]) VALUES ('" _
    & strValue & "')"

    CurrentDb.Execu te strSQl
    End Sub

    The following is an example of adding the entire contentsof a folder

    Function wut()
    Dim strFile As String
    Const FOLDER_PATH = "D:\Projects\Pi nnacle\Tools\Au tomation
    Wizard\Audit\"

    strFile = Dir(FOLDER_PATH & "*.txt")
    Do While Len(strFile) > 0
    Call AddHyperLink("t lHyperLink", "File", FOLDER_PATH & strFile,
    strFile)
    strFile = Dir
    Loop
    End Function


    If you have one filename you could do the folloing
    Call AddHyperLink("t lHyperLink", "File", YourFileName,
    Dir(YourFileNam e))






    --

    Terry Kreft


    "jodyblau" <jodyblau@gmail .com> wrote in message
    news:1138602740 .449300.12850@g 49g2000cwa.goog legroups.com...[color=blue]
    > I am trying to go through a list of files in a folder and then add a
    > hyperlink to each one in a table.
    >
    > I am having a difficult time figuring out how to add that link into the
    > table and do it in such a way that the entire path isn't displayed in
    > the record, just the document name (just like I can make it look if I
    > add the hyperlink by hand and then edit it using the dialog.)
    >
    > I have tried figuring it out using this article: (but I still don't get
    > it)
    >[/color]
    http://msdn.microsoft.com/archive/de...plications.asp[color=blue]
    >
    > Could someone kindly walk me through how to get from having a String
    > with my file path stored in it, to adding it to my table, such that the
    > link only displays the document name and not the full path?
    >
    > Thank you,
    >
    > Jody Blau
    >[/color]


    Comment

    • jodyblau

      #3
      Re: Hyperlink walkthrough

      That worked great, thank you so much.


      Jody Blau

      Comment

      Working...