Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default set var to folder path using Open Dialogue box

I have a spreadsheet application that is hard coded to search a folder on our
network. With the click of a button, it loops through all the access
databases in this folder and performs record count queries on twelve tables
(with the same table names in each database-just the databases have different
names) and prints the database name, table and record count in excel. It
works great.

Now I would like the user to be able to click a button on the spreadsheet
and have the open dialogue box (or some other control where they can select
a FOLDER---NOT A FILE!!) pop up and have them select the folder and have
this path saved in a variable. Then i will insert the variable name where I
currently have the path hard coded. then they can click the start button as
usual.

I tried using Application.GetOpenFilename but that makes you select a file.
I need the user to be able to select a folder and I don't want the folder
opened. I just want the path saved in a variable and I'm not sure how to do
this.

Thanks


--
Billy Rogers

Dallas,TX

Currently Using Office 2000
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default set var to folder path using Open Dialogue box

With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MsgBox .SelectedItems(1)
End With


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"BillyRogers" wrote in message
...
I have a spreadsheet application that is hard coded to search a folder on

our
network. With the click of a button, it loops through all the access
databases in this folder and performs record count queries on twelve

tables
(with the same table names in each database-just the databases have

different
names) and prints the database name, table and record count in excel. It
works great.

Now I would like the user to be able to click a button on the spreadsheet
and have the open dialogue box (or some other control where they can

select
a FOLDER---NOT A FILE!!) pop up and have them select the folder and have
this path saved in a variable. Then i will insert the variable name where

I
currently have the path hard coded. then they can click the start button

as
usual.

I tried using Application.GetOpenFilename but that makes you select a

file.
I need the user to be able to select a folder and I don't want the folder
opened. I just want the path saved in a variable and I'm not sure how to

do
this.

Thanks


--
Billy Rogers

Dallas,TX

Currently Using Office 2000



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 78
Default set var to folder path using Open Dialogue box

I don't think that works in Excel 2000. We are supposed to be getting
Office 2003 next month though, so I'll be able to use it then.


--
Billy Rogers

Dallas,TX

Currently Using Office 2000


"Bob Phillips" wrote:

With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MsgBox .SelectedItems(1)
End With


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"BillyRogers" wrote in message
...
I have a spreadsheet application that is hard coded to search a folder on

our
network. With the click of a button, it loops through all the access
databases in this folder and performs record count queries on twelve

tables
(with the same table names in each database-just the databases have

different
names) and prints the database name, table and record count in excel. It
works great.

Now I would like the user to be able to click a button on the spreadsheet
and have the open dialogue box (or some other control where they can

select
a FOLDER---NOT A FILE!!) pop up and have them select the folder and have
this path saved in a variable. Then i will insert the variable name where

I
currently have the path hard coded. then they can click the start button

as
usual.

I tried using Application.GetOpenFilename but that makes you select a

file.
I need the user to be able to select a folder and I don't want the folder
opened. I just want the path saved in a variable and I'm not sure how to

do
this.

Thanks


--
Billy Rogers

Dallas,TX

Currently Using Office 2000




  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default set var to folder path using Open Dialogue box

Okay, if you don't have 2002 or later try this


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

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

Private 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

'-------------------------------------------------------------
Function GetFolder(Optional ByVal Name As String = _
"Select a folder.") As String
'-------------------------------------------------------------
Dim bInfo As BROWSEINFO
Dim path As String
Dim oDialog As Long

bInfo.pidlRoot = 0& 'Root folder = Desktop

bInfo.lpszTitle = Name

bInfo.ulFlags = &H1 'Type of directory to Return
oDialog = SHBrowseForFolder(bInfo) 'display the dialog

'Parse the result
path = Space$(512)

GetFolder = ""
If SHGetPathFromIDList(ByVal oDialog, ByVal path) Then
GetFolder = Left(path, InStr(path, Chr$(0)) - 1)
End If

End Function

BTW, hardly seems worth getting 2003. 2000 is not much different, and 2007
comes out next year.

--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"BillyRogers" wrote in message
...
I don't think that works in Excel 2000. We are supposed to be getting
Office 2003 next month though, so I'll be able to use it then.


--
Billy Rogers

Dallas,TX

Currently Using Office 2000


"Bob Phillips" wrote:

With Application.FileDialog(msoFileDialogFolderPicker)
.Show
MsgBox .SelectedItems(1)
End With


--
HTH

Bob Phillips

(remove nothere from email address if mailing direct)

"BillyRogers" wrote in message
...
I have a spreadsheet application that is hard coded to search a folder

on
our
network. With the click of a button, it loops through all the access
databases in this folder and performs record count queries on twelve

tables
(with the same table names in each database-just the databases have

different
names) and prints the database name, table and record count in excel.

It
works great.

Now I would like the user to be able to click a button on the

spreadsheet
and have the open dialogue box (or some other control where they can

select
a FOLDER---NOT A FILE!!) pop up and have them select the folder and

have
this path saved in a variable. Then i will insert the variable name

where
I
currently have the path hard coded. then they can click the start

button
as
usual.

I tried using Application.GetOpenFilename but that makes you select a

file.
I need the user to be able to select a folder and I don't want the

folder
opened. I just want the path saved in a variable and I'm not sure how

to
do
this.

Thanks


--
Billy Rogers

Dallas,TX

Currently Using Office 2000






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
Preview in Open Dialogue Juli Excel Discussion (Misc queries) 4 May 31st 07 09:21 PM
When i open excel on the start dialogue, it does not open. lemon8 Setting up and Configuration of Excel 1 December 14th 05 05:37 AM
"Folder Select" Dialogue - Opening multiple files from selected folder Rob[_26_] Excel Programming 2 September 30th 05 02:47 PM
Get Folder Path RNM[_2_] Excel Programming 1 August 8th 04 03:19 AM
Open Dialogue Box to a certain folder????? German[_2_] Excel Programming 5 November 25th 03 11:55 PM


All times are GMT +1. The time now is 04:42 PM.

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

About Us

"It's about Microsoft Excel"