Hi everybody, I am using MkDir to create folders and I would like to be able to assign the file path of the folder that was just created to a variable...
so for example, in the code below I'm getting the user to choose the FldrRoot location and then creating several new folders here.
I've just commented out some of the stuff that doesn't pertain to this specific question
I would also like to use these file path variables in other subs later on so do I need to make this Sub public or just move those variables above the Sub() line?
Thanks all!
Cheers,
Joe
__________________________________________________________________
so for example, in the code below I'm getting the user to choose the FldrRoot location and then creating several new folders here.
I've just commented out some of the stuff that doesn't pertain to this specific question
Code:
Sub MergeWbks()
'Dim fsoMain As New FileSystemObject
Dim FldrRoot As String
'Dim myFldr As Folder
'Dim myWB As Workbook, tempWB As Workbook
'Dim fl As File
Dim FldrLvl1 As String
'Dim FldrLvl2 As String
'Dim FldrLvl3 As String
Dim xDirectRoot$, InitialFoldr$
Dim AMDExt As String
Dim PAABMgmt As String
Dim Jones As String
Dim FComp As String
'
InitialFoldr$ = "H:\"
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = Application.DefaultFilePath & "\"
.Title = "Please select the folder containing the PVS's for the Roll Year under Appeal"
.InitialFileName = InitialFoldr$
.Show
If .SelectedItems.Count <> 0 Then
xDirectRoot$ = .SelectedItems(1) & "\"
Else
End If
End With
Application.ScreenUpdating = False
FldrRoot = xDirectRoot$
MkDir (FldrRoot & "\" & "Amendments Extract") '//\\
'//How do I assign the file path created above to the variable AMDExt? \\
MkDir (FldrRoot & "\" & "PAAB Mgmt Reports") '//\\
'//How do I assign the file path created above to the variable PAABMgmt? \\
MkDir (FldrRoot & "\" & "Jones Reports") '//same as above\\
MkDir (FldrRoot & "\" & "Formatted Reports") '//same as above\\
On Error GoTo 0 '//resume errors\\
'I will then save some files to these folders...
'Next I will attempt to loop through each folder and merge these files... it seems so simple, but I just can't figure it out
Set myFldr = fsoMain.GetFolder("I want to use each of the MkDir file path variables here so that I can merge all the files I will have saved in them")
Set myWB = ActiveWorkbook
For Each fl In myFldr.Files
'There will be more code below...
I would also like to use these file path variables in other subs later on so do I need to make this Sub public or just move those variables above the Sub() line?
Thanks all!
Cheers,
Joe
__________________________________________________________________
Mod edit : post moved to appropriate forum …
Last edited: