|
Question : How to change open directory in msoFileDialogOpen (Excel Vba)
|
|
Hello All,
I'm using a file open dialog which I need for open multiple files and do some operations on it. My problem is that everytime its open the intial directory is "My Documents". How do I change the Intial Directory (for example c:\temp)? I'm using FileDialog(msoFileDialogOpen) but I cant find the property that I need.
Here is my code:
-------------------------------
UserForm1.ListBox2.Clear Dim lngCount As Long Dim strFileNames() As String Dim objExcel As Excel.Application Set objExcel = New Excel.Application Call DoesDirExist ' Open the file dialog With objExcel.FileDialog(msoFileDialogOpen) .AllowMultiSelect = True .Show For lngCount = 1 To .SelectedItems.count ReDim Preserve strFileNames(lngCount - 1) 'Array starts at zero. UserForm1.ListBox2.AddItem .SelectedItems(lngCount) Next lngCount End With objExcel.quit Set objExcel = Nothing
---------------------
Thanks, Eyal Keren
|
|
Answer : How to change open directory in msoFileDialogOpen (Excel Vba)
|
|
Hi Eyal,
Have you tried this?
With objExcel.FileDialog(msoFileDialogOpen) .AllowMultiSelect = True .InitialFileName = "C:\NicoReport\" ' Initial starting directory... .Show For lngCount = 1 To .SelectedItems.Count ReDim Preserve strFileNames(lngCount - 1) 'Array starts at zero. UserForm1.ListBox2.AddItem .SelectedItems(lngCount) Next lngCount End With
Jim
|
|
|