Move documents from one folder to another...

AndyD

Active Member
Joined
Nov 14, 2002
Messages
449
Hi I want to move pdfs from older folder to another: for example:

from C:/folder 1 to C:/folder 2

How do I do this?

Regards

Andy
 

Excel Facts

What is the fastest way to copy a formula?
If A2:A50000 contain data. Enter a formula in B2. Select B2. Double-click the Fill Handle and Excel will shoot the formula down to B50000.
Andy

Can't you just open Windows Explorer, goto folder 1, select all the files required, right click, select cut, goto folder 2, right click and select paste?

Or am I missing something?:)
 
Upvote 0
Hi
that would work fine however I want to suggest this as alternative as there are actually a large number of folders

Andy
 
Upvote 0
Andy

So do you want to do this in code?

If so you probably want to look at the following.

1 The Name statement.

2 The FileCopy statement.

3 The File System Object.

The first 2 will work with individual files, but could work in a loop.

I think, but I'm not 100% sure, that with the 3rd you could move multiple files in one go.

Can you give more details of what you actually want to do?
 
Upvote 0
hi
what I want to be able to do is for users to click on a button called, for example, "Move from folder 1 to folder" and for the macro to move all documents to the appropriate folder.

The next stage would be for the user to move from folder 2 to folder 3 etc, etc

Hope makes sense

Cheers

Andy
 
Upvote 0
Andy

But where do you want to do this?

This is an Excel forum, but you've not mentioned Excel so far.:)
 
Upvote 0
Sorry...

:biggrin:

In a excel worksheet, user presses on a button that says for example "Move documents to folder 2"....

Pressing this moves the documents in folder 1 to folder 2

I know it can be done as seen it before (and I can't find by searching)

Can you help?

Cheers

Andy
 
Upvote 0
Andy

Here's one way.
Code:
Sub Test()
Dim strSrcDir As String
Dim strDstDir As String
Dim I As Long

    strSrcDir = "C:\Folder1\"
    strDstDir = "C:\Folder2\"
    
    With Application.FileSearch
        .NewSearch
        .LookIn = strSrcDir
        .FileType = msoFileTypeAllFiles
        .Execute
        For I = 1 To .FoundFiles.Count
            Name (.FoundFiles(I)) As strDstDir & Dir(.FoundFiles(I))
        Next I
    End With

End Sub
If you paste this in a module (Insert>Module) in the VBA editor (ALT+F11) you can then add a button to a worksheet and assign the code to it using Assign macro...
 
Upvote 0

Forum statistics

Threads
1,214,646
Messages
6,120,717
Members
448,985
Latest member
chocbudda

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top