How to depict a changing doc name in VB hyperlink script

2247
1
06-13-2016 07:24 AM
Highlighted
New Contributor

I am trying to hyperlink PDF Floor Plans through Facility Number in VB Script Field Calculator.

My issue is that there are about 859 Floor Plans and each has a different name but starts with a Facility Number.  I have no issue matching the Facility Number but what do I do about the varying string description that vary in length and contain numbers.

Example:

Facility Number = A123

Floor Plan = A123_Admin_Hall_2016.pdf

This is what I have so far, how do I incorporate the string?? Are there wild card characters I can use?

"S:\DPW\Eng Record Management\Floor Plans" & [facilityNumber] & .pdf"

Thanks!!!

Reply
0 Kudos
1 Reply
Highlighted
Regular Contributor II

I am assuming that you are searching a directory for the Plan files......

Here is an Idea to get you started...this if not very efficient but I do not have a lot to go on but guesses:

Imports System

Imports System.IO

    Function GetFileInfo(FacilityNumber as string) as string

     Dim GFI as string

     GFI = ""

     ' Make a reference to a directory.

      Dim di As New DirectoryInfo("S:\DPW\Eng Record Management\Floor Plans\")

      ' Get a reference to each file in that directory.

      Dim fiArr As FileInfo() = di.GetFiles()

      ' Display the names of the files.

      Dim fri As FileInfo

      For Each fri In fiArr

          if left(fri.Name,3) = FacilityNumber then

              GFI = fri.name

              exit for

          end if

     Next fri

     if GFI = "" then

        GetFileInfo = "No Plans Found"

     else

        GetFileInfo = GFI

    End Function

Reply
0 Kudos