small question

viper

Active Member
Joined
Feb 15, 2002
Messages
382
Is there anyway to specify what directory my macro copies. I am using a macro to copy a sheet, e-mail it, then delete the sheet. I've ran into a problem now in that when my macro copies the sheet it copies it to a directory where my delete macro won't work.
I thought it should stay in the directory where the file I had open was in but for some reason my copies end up in an NT folder.
My delete macro has the code to look into a specific folder:D:docs
Can I change the code of the copy to:
Sheet(1).Copy ("D:docs")

Or will I need to change my delete macro to search for the file?

Thanks,
 

Excel Facts

Formula for Yesterday
Name Manager, New Name. Yesterday =TODAY()-1. OK. Then, use =YESTERDAY in any cell. Tomorrow could be =TODAY()+1.
Hi Viper,

I'm not entirely sure what you're asking. When you use the Copy method without using the Before or After arguments that sheet will be copied to a new workbook - right? The workbook won't be saved until you either save it manually or do it through code. Would this not do what you need?

Sheets(1).Copy
ActiveWorkbook.SaveAs "C:any folder you wantany name.xls"

If this isn't what you're talking about then please post your code.

Regards,
Dan
 
Upvote 0
Yes, your post is what I needed. In my code I just saved it as the name I wanted it to be saved as. I assumed that the file would be saved in the directory that the main file was in. Through me for a loop when my file was saved in a different location. I can specify where the file will be saved at and that should take care of the situation.
Thanks for your reply.
 
Upvote 0

Forum statistics

Threads
1,213,560
Messages
6,114,306
Members
448,564
Latest member
ED38

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