Wrox Programmer Forums
|
Access VBA Discuss using VBA for Access programming.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access VBA section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
 
Old August 9th, 2005, 01:20 AM
Authorized User
 
Join Date: Mar 2005
Posts: 10
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Suomi
Default OpenFileDialog using vba


Hi all,
I am looking for VBA code of Open File dialogue box. I need to use it in ACCESS. I have done the same in VB.Net using 'OpenFileDialog'. i.e I am looking for OpenFileDialog equalent of VB.net in ACCESS.
Basically my purspose is to let user select a file using open file dialogue box. After succesful selection, the path of the selected file would be utilized later on.
I'll be very thankful to you people for any kind of help in this regards.
Cheers,
Suomi

 
Old August 13th, 2005, 02:14 AM
Friend of Wrox
 
Join Date: Jul 2005
Posts: 150
Thanks: 0
Thanked 0 Times in 0 Posts
Default

check out: Call the standard Windows File Open/Save dialog box

I think I say your same question at http://www.utteraccess.com

Boyd
"Hi Tech Coach"
Access Based Accounting/Business Solutions developer.
http://www.officeprogramming.com
 
Old August 31st, 2005, 10:17 AM
Registered User
 
Join Date: Aug 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Is there no shorter method ?

 
Old September 8th, 2005, 03:34 PM
Authorized User
 
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

You need first to Open a reference to the Microsft Office 10.0 (or later) library and this allows you to use

Application.FileDialog(msoFolderPicker) or ...(msoFilePicker)

If you follow the example in the Help topic associated with it, you can then set a Folder or File to be a variable in your code. One thing to be careful of as it is not mentioned in the Help topic is that when you open the FileDialog object you must set the variable the holds the valus of the File/Folder selected to be a Variant otherwise the system will do nothing, not even report an error.

Good Luck





 
Old September 8th, 2005, 03:45 PM
Authorized User
 
Join Date: Jul 2004
Posts: 46
Thanks: 0
Thanked 1 Time in 1 Post
Default

I knew I had some code lying around. Try this

Dim fd As FileDialog
Dim objfl As Variant
Dim filnam As String

... other code .....

Set fd = Application.FileDialog(msoFileDialogFilePicker)
With fd
    .ButtonName = "Select"
    .AllowMultiSelect = False
    .Filters.Add "Text Files", "*.txt;*.csv;*.tab;*.asc", 1
    .title = "Choose Transactions file to import"
    .InitialView = msoFileDialogViewDetails
    .Show
    For Each objfl In .SelectedItems
        filnam = objfl
    Next objfl
    On Error GoTo 0
End With

Set fd = Nothing

''' filnam then used in following code . Note that although .AllowMultiSelect is set to False, you still need to run through the For each loop.

Hope this helps


 
Old March 26th, 2006, 07:21 AM
Registered User
 
Join Date: Mar 2006
Posts: 8
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Guys i am getting this error in VB.net "Type OpenFileDialog is not defined" which class should i import?

 
Old March 26th, 2006, 11:45 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Hi patrique,

The OpenFileDialog component lives in the System.Windows.Forms namespace which lives in the System.Windows.Forms.dll.

So add a reference to System.Windows.Forms.dll, then use the followiing Imports statement:

Imports System.Windows.Forms

HTH,

Bob

 
Old March 26th, 2006, 11:51 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
Default

Or just add a reference to System.Windows.Forms.dll and declare your component variable as:

Dim openFileDialog As New System.Windows.Forms.OpenFileDialog

without using the Imports statment.

Bob

 
Old August 20th, 2006, 11:25 AM
Authorized User
 
Join Date: Dec 2005
Posts: 17
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Found the answers at:

http://msdn.microsoft.com/library/de...HV03083230.asp
 
Old June 13th, 2007, 01:07 PM
Registered User
 
Join Date: Jun 2007
Posts: 1
Thanks: 0
Thanked 0 Times in 0 Posts
Default

The following URL documents the FileDialog object for Office 2007 -http://msdn2.microsoft.com/en-us/library/aa432348.aspx






Similar Threads
Thread Thread Starter Forum Replies Last Post
OpenFileDialog on .NET Compact Framework yukijocelyn C# 2005 0 July 4th, 2008 11:35 PM
Drag/Drop from OpenFileDialog using C# Windows App MukeshAgarwal C# 1 July 10th, 2007 10:44 AM
Using the OpenFileDialog johno BOOK: Beginning VB.NET 2nd Edition/Beginning VB.NET 2003 7 May 28th, 2007 02:57 AM
Code works in Excel VBA but not Access VBA fossx Access VBA 2 May 21st, 2007 08:00 AM
OpenfileDialog class krellee General .NET 1 September 14th, 2005 01:24 PM





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.