K
Keeley
Hello
I am trying to concatenate a chosen folder with a set
directory. The command line specifying the full path
works fine (see below). I added the input box to ask for
the folder name, this also works ok, the WhereName and
WFullName variable are filled with the correct data. It
just doesn't like using my WFullName or WhereName in the
Const SPth command line.
Thank you for your time.
Keeley.
Private Sub UserForm_Activate()
Dim i As Integer
Dim WhereName As String
Dim WFullName As String
WhereName = InputBox("Please enter name of
folder", "Choose Sub Folder")
WFullName = "C:\" & WhereName
Const sPth = WFullName (doesn't work)
'Const sPth = "C:\" & WhereName (doesn't work)
'Const sPth = "C:\test\" (works-but need more flexibility)
With Application.FileSearch
.NewSearch
.LookIn = sPth
.FileName = "*.doc"
.Execute msoSortByFileName
For i = 1 To .FoundFiles.Count
UserForm3.ListBox1.AddItem .FoundFiles(i)
Next
End With
End Sub
I am trying to concatenate a chosen folder with a set
directory. The command line specifying the full path
works fine (see below). I added the input box to ask for
the folder name, this also works ok, the WhereName and
WFullName variable are filled with the correct data. It
just doesn't like using my WFullName or WhereName in the
Const SPth command line.
Thank you for your time.
Keeley.
Private Sub UserForm_Activate()
Dim i As Integer
Dim WhereName As String
Dim WFullName As String
WhereName = InputBox("Please enter name of
folder", "Choose Sub Folder")
WFullName = "C:\" & WhereName
Const sPth = WFullName (doesn't work)
'Const sPth = "C:\" & WhereName (doesn't work)
'Const sPth = "C:\test\" (works-but need more flexibility)
With Application.FileSearch
.NewSearch
.LookIn = sPth
.FileName = "*.doc"
.Execute msoSortByFileName
For i = 1 To .FoundFiles.Count
UserForm3.ListBox1.AddItem .FoundFiles(i)
Next
End With
End Sub