Macro VBA to save/copy specific files located at specific folder to another folder that the user can choose with a folder dialog

prati

Board Regular
Joined
Jan 25, 2021
Messages
51
Office Version
  1. 2019
Platform
  1. Windows
Hey

I have macros that creates several pdf files at specific folder.
The file names are as follows:

Article.pdf
Article.part1.pdf
Article.part2.pdf
Article.part3.pdf

The files are always in pdf format

The location is always C:\Temp

The filenames are always the same

In another words the paths of those four files and the names remain the same as follows:

C:\Temp\Article.pdf
C:\Temp\Article.part1.pdf
C:\Temp\Article.part2.pdf
C:\Temp\Article.part3.pdf

Until now it was a background of several macros that in the end produces those files - Now I will get to my question.

Now I would like to ask for help in order to write a new macro with my very little knowledge.

I'm searching for a Macro VBA that will prompt the user to save those four specific files with folder dialog.

In another words the macro will open a folder dialog and ask the user where does he want to save those four specific files - and copy them to the choosen folder

With my current little Knowledge I only know how to copy a file from a specific location to another specific location

Sub Copy_Four_Files()

FileCopy "C:\Temp\article.pdf", "C:\AnotherLocation\article.pdf"
FileCopy "C:\Temp\article.part1.pdf", "C:\AnotherLocation\article.part1.pdf"
FileCopy "C:\Temp\article.part2.pdf", "C:\AnotherLocation\article.part2.pdf"
FileCopy "C:\Temp\article.part3.pdf", "C:\AnotherLocation\article.part3.pdf"

End Sub

I want to change the Macro so that the user can choose where to save/copy those four specific files, and if possible also to rename the files during the process of the folder dialog / save as.

Thanks in advance,
 
Hey,
Very nice job indeed.
I wonder whether It is possible to make small changes giving the possibility to rename the files during the process. In another words, not only moving them to another folder but also to rename the files.
Renaming file is quite easy. See sample here

 
Upvote 0

Excel Facts

Which lookup functions find a value equal or greater than the lookup value?
MATCH uses -1 to find larger value (lookup table must be sorted ZA). XLOOKUP uses 1 to find values greater and does not need to be sorted.
could i ask on this if the source folder was not a constant, what would need to be done to this code to allow the source folder to be selected each time the macro is run?
 
Upvote 0
could i ask on this if the source folder was not a constant, what would need to be done to this code to allow the source folder to be selected each time the macro is run?
I think this is what you need. The solution here from @Fluff our MrExcel MVP

 
Upvote 0

Forum statistics

Threads
1,224,823
Messages
6,181,181
Members
453,022
Latest member
Mohamed Magdi Tawfiq Emam

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