Hyperlink in word

  • Hy,

    I want to insert a particular hyperlink in Word 2000/XP. It should link another word document but which has not a fixed name.
    Its name is like
    aaaa_01.doc or
    aaaa_02.doc or
    or any version of the document. I would like to insert a hyperlink in word that feches always the last edited document that starts with aaaa_
    it would be something like aaaa_0?.doc, but I can't make it work.
    Is there any whay to do such thing?

  • Hi and welcome to the board :)

    If I understand You correctly You want to create a hyperlink for the latest edit document that have the prefix "aaaa"

    Are the document stored in the same folder?
    Are the document regular updated and what trigger the update?

  • yes, aaaa would be any name, but the important thing is that it stays always the same.
    The documents are stored in the same folder, and are updated manually. If someone wants to change the document, he does and saves the new document with the same name, plus the version number.
    This would make the hyperlink useless, but the hyperlink should update itself to. Maybe it's a crazy thing and it can't be done...

  • Hi,

    Here is a sample which You need to adjust before implementing it:

    Following procedure is inserted in the module "ThisDocument":

    Option Explicit

    Private Sub Document_Open()
    'Whenever this document is open it check for the latest
    'running file-number by calling the procedure.
    Call ChangeHyperlink
    End Sub

    Following code are inserted in a general module which You must create via the Insert | Module command.

    Option Explicit

    Sub ChangeHyperlink()
    'We need to set a reference to the Microsoft Scipting Runtime-library
    'via the Tools | Reference... in the VB-editor.
    Dim hlLink As Hyperlink
    Dim fsoObj As Scripting.FileSystemObject
    Dim fsoMapp As Scripting.Folder
    Dim fsoFil As Scripting.File
    Dim i As Long, j As Long

    Set fsoObj = New Scripting.FileSystemObject
    'Here we assume that the files are stored in the same folder
    'as the master-file.
    Set fsoMapp = fsoObj.GetFolder(ThisDocument.Path)

    'Here we loop trough the aaaa-files:
    i = 0
    j = 0
    If Not fsoMapp Is Nothing Then
    For Each fsoFil In fsoMapp.Files
    If fsoFil.Name Like "aaaa*.doc" Then
    i = Mid(fsoFil.Name, 5, 1)
    If i > j Then
    j = i
    Else: j = j
    End If
    End If
    Next fsoFil
    End If

    'Here we assume that it exist several links and
    'therefore we need to loop throguh them all:
    For Each hlLink In ActiveDocument.Hyperlinks
    If hlLink.Address Like "aaaa*" Then
    With hlLink
    .Address = "aaaa" & j & ".doc"
    End With
    Exit For
    End If
    Next hlLink

    End Sub

    ..and as we say: Can do :cool:

Participate now!

Don’t have an account yet? Register yourself now and be a part of our community!