Visual Basic Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread Dev Shed Forums Sponsor:
Stop making mediocre tutorials.The best tutorials are video! Camtasia Studio makes it easy to create engaging, buzz-building screen videos at any size, in any popular format. Download the free trial!
  #1  
Old September 12th, 2003, 12:27 PM
kuulaak kuulaak is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 kuulaak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Get Folder

I am working on some forms in access and looking for a way to get a user to broswe for a folder destination that i can then use as a destination for some exports.

Reply With Quote
  #2  
Old September 13th, 2003, 06:32 AM
ajmh ajmh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Aug 2003
Location: UK
Posts: 19 ajmh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
You can use the Microsoft Common Dialog Control (comdlg32.ocx) which should be located in your windows\system32 directory.

This control will allow you to use the windows common dialogs - which includes things like the color picker, printer dialog, and the file-open and file-save dialog windows.

If you place an instance of the CommonDialog Control on your form along with a command button then try the code below:

Private Sub Command1_Click()
CommonDialog1.ShowSave
MsgBox CommonDialog1.FileName
End Sub


The FileName property of the control should return the file the user selects/type in and the path.

Hope this helps + good luck with your project.

Reply With Quote
  #3  
Old September 15th, 2003, 11:48 AM
kuulaak kuulaak is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Sep 2003
Posts: 2 kuulaak User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
thanks for the tip

I ended up using the methods described here

URL

seems to work pretty well, except no "New Folder" button

Reply With Quote
  #4  
Old September 16th, 2003, 12:15 AM
cleverpig cleverpig is offline
Contributing User
Dev Shed Beginner (1000 - 1499 posts)
 
Join Date: Jul 2003
Posts: 1,152 cleverpig User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 6
Send a message via MSN to cleverpig
Here is a small tip that describes how to open the Browse for folder dialog via API from VB. With the Browse for folder dialog a user can select an existing directory from a directory tree. This example is build around a Function that will display the Browse for folder dialog and returns a directory if one is selected. This tip is inspired by code from VBnet.




Add this code to a Module:

Option Explicit
Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
"SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) As Long

Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
"SHGetPathFromIDListA" (ByVal pidl As Long, _
ByVal pszPath As String)As Long

Const BIF_RETURNONLYFSDIRS = &H1

Type BROWSEINFO
hOwner As Long
pidlRoot As Long
pszDisplayName As String
lpszTitle As String
ulFlags As Long
lpfn As Long
lParam As Long
iImage As Long
End Type

Type ****EMID
cb As Long
abID As Byte
End Type

Type ITEMIDLIST
mkid As ****EMID
End Type
'-- End --'


Add this code to the Form:

Function GetBrowseDirectory(Owner As Form) As String
Dim bi As BROWSEINFO
Dim IDL As ITEMIDLIST
Dim r As Long
Dim pidl As Long
Dim tmpPath As String
Dim pos As Integer

bi.hOwner = Owner.hwnd
bi.pidlRoot = 0&
bi.lpszTitle = "Choose a directory from the list."
bi.ulFlags = BIF_RETURNONLYFSDIRS
pidl = SHBrowseForFolder(bi)

tmpPath = Space$(512)
r = SHGetPathFromIDList(ByVal pidl, ByVal tmpPath)

If r Then
pos = InStr(tmpPath, Chr$(0))
tmpPath = Left(tmpPath, pos - 1)

If Right(tmpPath, 1) <> "\" Then tmpPath = tmpPath & "\"
GetBrowseDirectory = tmpPath
Else
GetBrowseDirectory = ""
End If

End Function
'-- End --'


Now you will be able to call the Browse for folder dialog by using the following line of code from your program:
Private Sub Form_Load()
Dim myDir As String
myDir = GetBrowseDirectory(Form1)
MsgBox myDir
End Sub
...where form1 is the form that will recieve all errormessages. myDir will hold the directory selected or "" (nothing) if selection is cancelled.

Last edited by cleverpig : September 16th, 2003 at 12:18 AM.

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreVisual Basic Programming > Get Folder


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


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
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump

 Free IT White Papers!
 
Accelerating Trading Partner Performance
One in five. That's how many partner transactions have at least one error. That is an amazing statistic, particularly given the extraordinary leaps in innovation across the global supply chain during the past two decades. Download this white paper to learn more.

 
Competing on Analytics
This Tech Analysis is designed to help identify characteristics shared by analytics competitors, and includes information about 32 organizations that have made a commitment to quantitative, fact-based analysis.

 
Cost Effective Scaling with Virtualization and Coyote Point Systems
An overview of the industry trend toward virtualization, how server consolidation has increased the importance of application uptime and the steps being taken to integrate load balancing technology with virtualized servers.

 
Five Checkpoints to Implementing IP Telephony
Implementation planning for IP PBX software and IP telephony has become vital as businesses replace discontinued legacy PBX phone systems. This informative whitepaper outlines five "checkpoints" for any implementation plan that will help make IP communications a successful proposition.

 
Hosted Email Security: Staying Ahead of New Threats
In the last two years, email has become a fierce battleground between the nefarious forces of spam and malware, and the heroes of messaging protection. The spam volumes increased alarmingly every month, bringing clever new forms of phishing and virus propagation attacks.

 

Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway