#1   Report Post  
saybut
 
Posts: n/a
Default file browser window


Hi,

I was wondernig if anyone could help me...

I have a macro which was written a while ago with some assitance from a
member of excelforum.

Basically it looks in one directory, and copies the files listed in
column A to anther directory. The code is below.

I'm looking now to expand this macro so that when I click the button
"copy files", a file browser window would open so that I can select the
relevant directory rather than changing it in script everytime I want to
look at a different folder. Ideally I'd have the same thing for the copy
destination.

If anyone could help it would be great, even to point me in the right
direction for getting vb to open a file browser.

macro:

Sub copy_files()
Dim rng As Range
Dim cell As Range
Dim SrcFilename As String
Dim DestFilename As String

Set rng = Selection
For Each cell In rng
SrcFilename = "\\network_location\" & cell.Value 'change source path
DestFilename = "\\network_location\" & cell.Value 'change destination
Path
FileCopy SrcFilename, DestFilename
Next
End Sub



Many thanks,

Mark.


--
saybut
------------------------------------------------------------------------
saybut's Profile: http://www.excelforum.com/member.php...fo&userid=5949
View this thread: http://www.excelforum.com/showthread...hreadid=395820

  #2   Report Post  
Jim Rech
 
Posts: n/a
Default

This is a simple demo of how you can have the user browse for a folder:

Sub ShowBrowseForFolder()
Dim Fld As Object
Set Fld = CreateObject("Shell.Application").BrowseForFolder( 0, "Select
source folder", 0, "c:\")
If Not Fld Is Nothing Then
MsgBox Fld.Self.Path
End If
End Sub

This dialog will have a Make New Folder button on it. If you don't want
that to appear replace the second zero with 512.

--
Jim
"saybut" wrote in
message ...
|
| Hi,
|
| I was wondernig if anyone could help me...
|
| I have a macro which was written a while ago with some assitance from a
| member of excelforum.
|
| Basically it looks in one directory, and copies the files listed in
| column A to anther directory. The code is below.
|
| I'm looking now to expand this macro so that when I click the button
| "copy files", a file browser window would open so that I can select the
| relevant directory rather than changing it in script everytime I want to
| look at a different folder. Ideally I'd have the same thing for the copy
| destination.
|
| If anyone could help it would be great, even to point me in the right
| direction for getting vb to open a file browser.
|
| macro:
|
| Sub copy_files()
| Dim rng As Range
| Dim cell As Range
| Dim SrcFilename As String
| Dim DestFilename As String
|
| Set rng = Selection
| For Each cell In rng
| SrcFilename = "\\network_location\" & cell.Value 'change source path
| DestFilename = "\\network_location\" & cell.Value 'change destination
| Path
| FileCopy SrcFilename, DestFilename
| Next
| End Sub
|
|
|
| Many thanks,
|
| Mark.
|
|
| --
| saybut
| ------------------------------------------------------------------------
| saybut's Profile:
http://www.excelforum.com/member.php...fo&userid=5949
| View this thread: http://www.excelforum.com/showthread...hreadid=395820
|


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
when i open a file a new excel window opens. how do stop this susan Excel Discussion (Misc queries) 1 July 1st 05 03:08 PM
open file in different window Anna Excel Discussion (Misc queries) 1 April 25th 05 09:33 PM
How do open each excel file in its own window pearcemi Excel Discussion (Misc queries) 2 March 10th 05 10:59 AM
Locating a file in excel with a partial file name. Audra Excel Discussion (Misc queries) 0 February 19th 05 02:03 PM
Read Text File into Excel Using VBA Willie T Excel Discussion (Misc queries) 13 January 8th 05 12:37 AM


All times are GMT +1. The time now is 10:37 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"