Move a file created by macro

sunilbsrv2k

Board Regular
Joined
May 25, 2018
Messages
73
Hi All,

I have a macro file, which on opening will create a file and save it in a folder.

I have created another macro to open the above macro file.

My question here is to move the file created by the above macro to a different folder.

Please help.

Below is my code:

Code:
Sub fcr_macro()

Dim wb As Workbook
Dim clname, compname As String
clname = Range("D2").Value
compname = Range("D3").Value
Set wb = Workbooks.Open("<path/file>")

wb.Close
End Sub
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
open the file
save the filepath to a variable
save the filename to a variable
set a variable with the destination path
close the file
filecopy the path and oldfilename destination path filename
kill original filepath and name

and all this in correct VBA syntax filecopy and kill are evalid commands, you do not have a file move or move command

and save the fullpath (path and filename) to a variable
close
 
Upvote 0
Ron's a great site

the syntax, just in case...
Code:
FileCopy myFullFileName, newPath & newfName
Kill myFullFileName

Of course you have to set the variables and the values for each, don't forget the final backslash in the newPath
 
Upvote 0
Hi All,

Thanks for your reply. Even the website you shared is also very good.

However, my issue here is slightly different.

the codeline: Set wb = Workbooks.Open("
") will open a file that contains a macro. And this macro will create a file in a folder.

I want this file created by above macro to be moved to a destination folder. And I want this to be accomplished in the above code mentioned in my first post above.

Could you please throw some light on this

Thanks
</path>
 
Upvote 0
You’ve got all the code you need so just place it in that macro an let do its work
I’ll see if I can pick this up after the soccer games later this evening
 
Upvote 0

Forum statistics

Threads
1,215,359
Messages
6,124,488
Members
449,166
Latest member
hokjock

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