petroj02
02-02-2017, 05:35 AM
Hello,
I would like to find and open pdf file which is located in many Folders and subfolders, The file Name I would like to find depends on user Input to TextBox. These Folders and sobfolders are created by the date/month/day
Here is a code how I create the path for new file
Sub createDateFolder() ' modul vytvarejici podslozku vzdy podle data
Dim fsoObj As Object, thedate As String
thedate = Format(Date, "DD/MM/YYYY")
If Len(Dir("V:\CGC_DATA\Orders\" & Year(Date), vbDirectory)) = 0 Then
MkDir "V:\CGC_DATA\Orders\" & Year(Date)
End If
If Len(Dir("V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False), vbDirectory)) = 0 Then
MkDir "V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False)
End If
enddir = ("V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & thedate & "\") 'cesta podslozky
Set fsoObj = CreateObject("Scripting.FileSystemObject")
With fsoObj
If Not .FolderExists(enddir) Then 'kdyz podslozka neexistuje modul ji vytvori
.CreateFolder (enddir)
End If
End With
End Sub
here is a code I have right now for finding the existing pdf file. Problem is that this way I can find only file from "today"...
Sub openOldList(ByVal oldList As String)
Dim thedate As String
thedate = Format(Date, "DD/MM/YYYY")
ThisWorkbook.FollowHyperlink "V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & thedate & "\" & oldList & ".pdf"
End Sub
But I am not able to find the way how to Loop all existing Folders after this path "V:\CGC_DATA\Orders\" and in These all Folders to find and open the pdf file I am searching for in TextBox.
I hope someone can pull me closer to my goal
I would like to find and open pdf file which is located in many Folders and subfolders, The file Name I would like to find depends on user Input to TextBox. These Folders and sobfolders are created by the date/month/day
Here is a code how I create the path for new file
Sub createDateFolder() ' modul vytvarejici podslozku vzdy podle data
Dim fsoObj As Object, thedate As String
thedate = Format(Date, "DD/MM/YYYY")
If Len(Dir("V:\CGC_DATA\Orders\" & Year(Date), vbDirectory)) = 0 Then
MkDir "V:\CGC_DATA\Orders\" & Year(Date)
End If
If Len(Dir("V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False), vbDirectory)) = 0 Then
MkDir "V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False)
End If
enddir = ("V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & thedate & "\") 'cesta podslozky
Set fsoObj = CreateObject("Scripting.FileSystemObject")
With fsoObj
If Not .FolderExists(enddir) Then 'kdyz podslozka neexistuje modul ji vytvori
.CreateFolder (enddir)
End If
End With
End Sub
here is a code I have right now for finding the existing pdf file. Problem is that this way I can find only file from "today"...
Sub openOldList(ByVal oldList As String)
Dim thedate As String
thedate = Format(Date, "DD/MM/YYYY")
ThisWorkbook.FollowHyperlink "V:\CGC_DATA\Orders\" & Year(Date) & "\" & MonthName(Month(Date), False) & "\" & thedate & "\" & oldList & ".pdf"
End Sub
But I am not able to find the way how to Loop all existing Folders after this path "V:\CGC_DATA\Orders\" and in These all Folders to find and open the pdf file I am searching for in TextBox.
I hope someone can pull me closer to my goal