Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default How to choose a folder


How can I get the user of a macro to choose a folder?

The code I have now, opens a specific file. However I want the user to
select a folder.

I want this as the macro is to open all the files in the selected
folder...

My code now:

Application.Workbooks.Open Filename:= _
"X:\Users\Shared\GENERAL\Christian S\05.10.28 - Budget packs -
Capital expenditure - comments\BFR " & Mnumb & " bud v1.xls" _
, UpdateLinks:=0


--
Ctech
------------------------------------------------------------------------
Ctech's Profile: http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=482149

  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 11,272
Default How to choose a folder

Here is some code that opens all files

Dim aryFiles
Dim oFSO

Sub LoopFolders()
Dim i As Integer

Set oFSO = CreateObject("Scripting.FileSystemObject")

selectFiles "c:\MyTest"

Set oFSO = Nothing

End Sub


'---------------------------------------------------------------------------
Sub selectFiles(sPath)
'---------------------------------------------------------------------------
Dim Folder As Object
Dim Files As Object
Dim file As Object
Dim fldr

Set Folder = oFSO.GetFolder(sPath)

For Each fldr In Folder.Subfolders
selectFiles fldr.Path
Next fldr

For Each file In Folder.Files
If file.Type = "Microsoft Excel Worksheet" Then
Workbooks.Open Filename:=file.Path
End If
Next file

End Sub


--

HTH

RP
(remove nothere from the email address if mailing direct)


"Ctech" wrote in
message ...

How can I get the user of a macro to choose a folder?

The code I have now, opens a specific file. However I want the user to
select a folder.

I want this as the macro is to open all the files in the selected
folder...

My code now:

Application.Workbooks.Open Filename:= _
"X:\Users\Shared\GENERAL\Christian S\05.10.28 - Budget packs -
Capital expenditure - comments\BFR " & Mnumb & " bud v1.xls" _
, UpdateLinks:=0


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:

http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=482149



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default How to choose a folder

http://www.j-walk.com/ss/excel/tips/tip29.htm
Selecting a directory

--
Regards,
Tom Ogilvy


"Ctech" wrote in
message ...

How can I get the user of a macro to choose a folder?

The code I have now, opens a specific file. However I want the user to
select a folder.

I want this as the macro is to open all the files in the selected
folder...

My code now:

Application.Workbooks.Open Filename:= _
"X:\Users\Shared\GENERAL\Christian S\05.10.28 - Budget packs -
Capital expenditure - comments\BFR " & Mnumb & " bud v1.xls" _
, UpdateLinks:=0


--
Ctech
------------------------------------------------------------------------
Ctech's Profile:

http://www.excelforum.com/member.php...o&userid=27745
View this thread: http://www.excelforum.com/showthread...hreadid=482149



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
Pulling pdf files from general folder to specific folder [email protected] Excel Discussion (Misc queries) 2 September 8th 09 09:41 PM
how can i change my default working folder to a networked folder? wizard1154 Excel Discussion (Misc queries) 4 April 18th 07 07:29 PM
How to decide folder-depth or How to select more folders/subfolders (folder-tree) ? Subteam Excel Discussion (Misc queries) 2 May 7th 06 08:14 PM
how can I specific a folder with wildcard criteria and excel will import all the correct files in that folder? Raven Excel Discussion (Misc queries) 1 January 24th 06 03:28 PM
ENTER DATE, CHOOSE WKSHEET, SAVE IN FOLDER jlegoland4 Excel Programming 2 September 1st 04 01:09 PM


All times are GMT +1. The time now is 11:52 PM.

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"