N
nx3
My code is below. Very simple, the users to select a directory and I'd like
to pick up where this has been previously set. This all works, it picksup the
directory, it changes the CurDir and msgbox it back all fine. Then the next
stage is the file browse dialog and is using somewhere else again ! How can I
set or control where the FileDialog(msoFileDialogFolderPicker) starts the
default view from ?
TIA
Public OldDir As String
Public ArchiveDir As String
Sub UseFileDialogOpen()
'Pick Up Current Directory
OldDir = CurDir
'Pick up archive directory
ArchiveDir = Sheets("Files").Range("B9").Value
'ArchiveDir = "C:\windows\"
'Test Archive Directory exists
If Dir(ArchiveDir, vbDirectory) <> "" Then
'If ArchiveDir Found
ChDir ArchiveDir
MsgBox CurDir
End If
' Open the file dialog
Set BrowseFolder = Application.FileDialog(msoFileDialogFolderPicker)
With BrowseFolder
.Show
If BrowseFolder.SelectedItems.Count > 0 Then
Var = .SelectedItems(1)
End If
End With
MsgBox Var
End Sub
to pick up where this has been previously set. This all works, it picksup the
directory, it changes the CurDir and msgbox it back all fine. Then the next
stage is the file browse dialog and is using somewhere else again ! How can I
set or control where the FileDialog(msoFileDialogFolderPicker) starts the
default view from ?
TIA
Public OldDir As String
Public ArchiveDir As String
Sub UseFileDialogOpen()
'Pick Up Current Directory
OldDir = CurDir
'Pick up archive directory
ArchiveDir = Sheets("Files").Range("B9").Value
'ArchiveDir = "C:\windows\"
'Test Archive Directory exists
If Dir(ArchiveDir, vbDirectory) <> "" Then
'If ArchiveDir Found
ChDir ArchiveDir
MsgBox CurDir
End If
' Open the file dialog
Set BrowseFolder = Application.FileDialog(msoFileDialogFolderPicker)
With BrowseFolder
.Show
If BrowseFolder.SelectedItems.Count > 0 Then
Var = .SelectedItems(1)
End If
End With
MsgBox Var
End Sub