dbTalk Databases Forums  

fDialog - Opens at a User defined Folder

comp.databases.ms-access comp.databases.ms-access


Discuss fDialog - Opens at a User defined Folder in the comp.databases.ms-access forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Rich P
 
Posts: n/a

Default Re: fDialog - Opens at a User defined Folder - 06-30-2010 , 11:41 AM






Hi Barry, I use the Microsoft Office Library for OpenFileDialog -- as
follows:

Private Sub Command1_Click()
Dim v As Variant
Dim f As FileDialog

'--make a reference to: Microsoft Office 11.0 Object
'--Library (or whatever Office version is current)

Set f = Application.FileDialog(msoFileDialogOpen)

f.Filters.Add "Text Documents", "*.txt"
f.InitialFileName = "C:\1C"
f.Show
For Each v In f.SelectedItems
Debug.Print v
Next
End Sub

Rich

*** Sent via Developersdex http://www.developersdex.com ***

Reply With Quote
  #2  
Old   
Barry Edmund Wright
 
Posts: n/a

Default fDialog - Opens at a User defined Folder - 06-30-2010 , 11:48 AM






Hi All,
I have the following code under a button click. The dialog opens to
display the "My Documents" folder. My question is how can I change it
to open at some other user specified folder, i.e., C:\Temp ? Thanks.

Dim varReturn As Variant
Dim varFile As Variant
Dim strDBDir As String
Dim strMsg As String
Dim db As Database
Dim varFileName As Variant
Dim tdf As TableDef
Dim intI As Integer
Dim intNumTables As Integer
Dim strProcName As String
Dim strFilter As String
Dim lngFlags As Long
Dim adhVerifyLinks As Boolean

Dim fDialog As Office.FileDialog

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = False

'Set the title of the dialog box.
.Title = "Please select one Access Database file"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB; *.ACCDB"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to the list box.
For Each varFile In .SelectedItems
varFileName = varFile
Next
Else
'MsgBox "You clicked Cancel in the file dialog box."
Exit Sub
End If
End With

Reply With Quote
  #3  
Old   
Salad
 
Posts: n/a

Default Re: fDialog - Opens at a User defined Folder - 06-30-2010 , 12:33 PM



Barry Edmund Wright wrote:

Quote:
Hi All,
I have the following code under a button click. The dialog opens to
display the "My Documents" folder. My question is how can I change it
to open at some other user specified folder, i.e., C:\Temp ? Thanks.

Dim varReturn As Variant
Dim varFile As Variant
Dim strDBDir As String
Dim strMsg As String
Dim db As Database
Dim varFileName As Variant
Dim tdf As TableDef
Dim intI As Integer
Dim intNumTables As Integer
Dim strProcName As String
Dim strFilter As String
Dim lngFlags As Long
Dim adhVerifyLinks As Boolean

Dim fDialog As Office.FileDialog

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = False

'Set the title of the dialog box.
.Title = "Please select one Access Database file"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB; *.ACCDB"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to the list box.
For Each varFile In .SelectedItems
varFileName = varFile
Next
Else
'MsgBox "You clicked Cancel in the file dialog box."
Exit Sub
End If
End With
I have some old code...http://www.mvps.org/access/api/api0001.htm/

There's a flag called InitialDir. I passed a folder to the function and
have this line it it.
InitialDir:=varDirectory,

Reply With Quote
  #4  
Old   
Barry Edmund Wright
 
Posts: n/a

Default Re: fDialog - Opens at a User defined Folder - 06-30-2010 , 01:25 PM



On Jun 30, 12:41*pm, Rich P <rpng... (AT) aol (DOT) com> wrote:
Quote:
Hi Barry, *I use the Microsoft Office Library for OpenFileDialog -- as
follows:

Private Sub Command1_Click()
* *Dim v As Variant
* *Dim f As FileDialog

* *'--make a reference to: *Microsoft Office 11.0 Object
* *'--Library (or whatever Office version is current)

* *Set f = Application.FileDialog(msoFileDialogOpen)

* *f.Filters.Add "Text Documents", "*.txt"
* *f.InitialFileName = "C:\1C"
* *f.Show
* *For Each v In f.SelectedItems
* * * Debug.Print v
* *Next
End Sub

Rich

*** Sent via Developersdexhttp://www.developersdex.com***
Thanks, worked like a charm - as suggested I just added the below line
to my code:
InitialFileName = "C:\Temp"

'Code Change
'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box.
.AllowMultiSelect = False

'Set the Dialog to open at a specified directory
.InitialFileName = "C:\Temp"

'Set the title of the dialog box.
.Title = "Please select one Access Database file"

'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Access Databases", "*.MDB; *.ACCDB"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
'Loop through each file selected and add it to the list box.
For Each varFile In .SelectedItems
varFileName = varFile
Next
Else
'MsgBox "You clicked Cancel in the file dialog box."
Exit Sub
End If
End With

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.