Good afternoon folks,
I'm looking for some assistance on how to write some code that will search a known drive and folder structure for a tif file and on finding it, open that tif file.
The known drive/folder structure is as follows:
M:\CustomerSatisfaction\StdDGImages
or it could have the full path as follows:
\\prdfs01\QUESTIONS\CustomerSatisfaction\StdDGImages
and then there are the following folders which contain any number of tif images:
01_Q
02_Q
03_Q
04_Q
05_Q
06_Q
07_Q
10_Q
11_Q
12_Q
13_Q
14_Q
17_Q
18_Q
19_Q
20_Q
21_Q
23_Q
24_Q
28_Q
29_Q
30_Q
31_Q
32_Q
33_Q
34_Q
35_Q
36_Q
37_Q
38_Q
39_Q
AR_Q
HE_Q
SKY_SKY3B
I would like to have a button in a form that the end user clicks and they then enter the name of the tif file they are looking for and on pressing enter the file is searched for and if found it is automatically opened up for them to see, if it is not found then a message "File Not Found" is displayed.
I Believe that I will need something like this:
I'm slowly learning about these things but I've got really stuck here, so any help would be greatly appreciated.
Regards
John
Edit: an example tif file I might search for is: 0H214_2CJ0001905.tif.
I'm looking for some assistance on how to write some code that will search a known drive and folder structure for a tif file and on finding it, open that tif file.
The known drive/folder structure is as follows:
M:\CustomerSatisfaction\StdDGImages
or it could have the full path as follows:
\\prdfs01\QUESTIONS\CustomerSatisfaction\StdDGImages
and then there are the following folders which contain any number of tif images:
01_Q
02_Q
03_Q
04_Q
05_Q
06_Q
07_Q
10_Q
11_Q
12_Q
13_Q
14_Q
17_Q
18_Q
19_Q
20_Q
21_Q
23_Q
24_Q
28_Q
29_Q
30_Q
31_Q
32_Q
33_Q
34_Q
35_Q
36_Q
37_Q
38_Q
39_Q
AR_Q
HE_Q
SKY_SKY3B
I would like to have a button in a form that the end user clicks and they then enter the name of the tif file they are looking for and on pressing enter the file is searched for and if found it is automatically opened up for them to see, if it is not found then a message "File Not Found" is displayed.
I Believe that I will need something like this:
Code:
[FONT=Times New Roman]Dim FS As FileSystemObject [/FONT]
[FONT=Times New Roman]Dim filenum As Integer [/FONT]
[FONT=Times New Roman]Dim tmp As String[/FONT]
[FONT=Times New Roman]Dim Folder As Folder[/FONT]
[FONT=Times New Roman]Dim subFolder As Folder[/FONT]
[FONT=Times New Roman]Dim File As File [/FONT]
[FONT=Times New Roman]Dim TiffFilePath[/FONT]
[FONT=Times New Roman]Dim NameOfFile[/FONT]
[FONT=Times New Roman]Dim FileNameWithExt [/FONT]
[FONT=Times New Roman]Dim strTemp As String [/FONT]
[FONT=Times New Roman]Dim FileLoc As String[/FONT]
[FONT=Times New Roman]Const ForReading = 1[/FONT]
[FONT=Times New Roman][FONT=Times New Roman]Set FS = CreateObject("Scripting.FileSystemObject")[/FONT][/FONT]
[FONT=Times New Roman][FONT=Times New Roman]TifFilePath = "B:\"[/FONT]
[/FONT]
[FONT=Times New Roman][FONT=Times New Roman]If Not FS.FolderExists(TifFilePath) Then[/FONT]
[FONT=Times New Roman]MsgBox "Folder Doesn't Exist", , "Reading Tif Files"[/FONT]
[FONT=Times New Roman] End[/FONT]
[FONT=Times New Roman]End If[/FONT]
[FONT=Times New Roman][FONT=Times New Roman]Set Folder = FS.GetFolder(TifFilePath)[/FONT][/FONT][/FONT]
[FONT=Times New Roman][FONT=Times New Roman][COLOR=red]It's when I get to this point that I've got stuck, I don't know how to structure the code required to do the search and on finding the tif file open it.[/COLOR][/FONT][/FONT]
I'm slowly learning about these things but I've got really stuck here, so any help would be greatly appreciated.
Regards
John
Edit: an example tif file I might search for is: 0H214_2CJ0001905.tif.