Hi
I've got the code below which opens the "Downloads" folder on my laptop, after which I choose a file to import.
However, I'd like to modify the code so that it opens the CURRENT folder that I'm in.
E.g if the files I'm using are all saved in "My Documents", then I'd want the code to go to that Directory.....
But if the files are all saved in "Desktop," then the code would go to that Directory.
Is it possible to write code which goes to the directory of the current file that is being worked on?
Option Explicit
Sub OpenDownloadsFolder()
Dim fd As FileDialog
Dim filewaschosen As Boolean
Dim Report As Workbook
Dim iWB As Workbook
Set Report = ActiveWorkbook
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.Filters.Clear
fd.Filters.Add "xlsx files", "*.xlsx"
fd.AllowMultiSelect = False
fd.InitialFileName = Environ("UserProfile") & "\Downloads"
filewaschosen = fd.Show
fd.Execute
End Sub
I've got the code below which opens the "Downloads" folder on my laptop, after which I choose a file to import.
However, I'd like to modify the code so that it opens the CURRENT folder that I'm in.
E.g if the files I'm using are all saved in "My Documents", then I'd want the code to go to that Directory.....
But if the files are all saved in "Desktop," then the code would go to that Directory.
Is it possible to write code which goes to the directory of the current file that is being worked on?
Option Explicit
Sub OpenDownloadsFolder()
Dim fd As FileDialog
Dim filewaschosen As Boolean
Dim Report As Workbook
Dim iWB As Workbook
Set Report = ActiveWorkbook
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.Filters.Clear
fd.Filters.Add "xlsx files", "*.xlsx"
fd.AllowMultiSelect = False
fd.InitialFileName = Environ("UserProfile") & "\Downloads"
filewaschosen = fd.Show
fd.Execute
End Sub