Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
nx3 nx3 is offline
external usenet poster
 
Posts: 8
Default FileDialog(msoFileDialogFolderPicker) not using the current direct

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
nx3 nx3 is offline
external usenet poster
 
Posts: 8
Default FileDialog(msoFileDialogFolderPicker) not using the current direct

To answer my own question as I was being silly... I need to set
..InitialFileName as per below and it works :)

' Open the file dialog
Set BrowseFolder = Application.FileDialog(msoFileDialogFolderPicker)
With BrowseFolder
.InitialFileName = ArchiveDir
.Show
If BrowseFolder.SelectedItems.Count 0 Then
Var = .SelectedItems(1)
End If
End With


"nx3" wrote:

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

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Opening each file in a folder using msoFileDialogFolderPicker Ayo Excel Discussion (Misc queries) 2 January 23rd 13 10:03 PM
Using Application.FileDialog(msoFileDialogFolderPicker) Ayo Excel Discussion (Misc queries) 1 March 12th 08 01:01 PM
FileDialog Mike Archer Excel Programming 0 May 28th 06 06:31 PM
using a filedialog box from a dll Paul Excel Programming 2 April 26th 06 04:56 PM
FileDialog Help Maynard Excel Programming 0 August 4th 04 01:43 PM


All times are GMT +1. The time now is 07:25 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"