Quicky

Adrac

Active Member
Joined
Feb 13, 2014
Messages
280
Office Version
  1. 365
Platform
  1. Windows
Hello gang,

Im trying to create a copy of my document and then change the name (without affecting the master copy) and save into desktop regardsless of username, as part of a macro. Can you suggest a workaround?

Adrac
 
ok i dont mind if the file is the same format but without "FileFormat:=xlOpenXMLWorkbookMacroEnabled" this line it will not work. The master spreadsheet is .xlsm and im guessing the fileformat is right?
 
Upvote 0

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.
The file format is the same, so that is not the problem. Can you try just having:

Code:
ThisWorkbook.SaveCopyAs Filename:="C:\Users\" & Environ$("Username") & _
"\Desktop\" & ThisWorkbook.Name & "_copy" [COLOR=#ff0000]& .xlsm[/COLOR]

instead of having the "File Format" part in there?
 
Upvote 0
almost there lol i have the .xlsm highlighted and the error "Compile error: Invalid or unqualified reference" :(
 
Upvote 0
Code:
ThisWorkbook.SaveCopyAs Filename:="C:\Users\" & Environ$("Username") & _
"\Desktop\" & ThisWorkbook.Name & "_copy[COLOR=#ff0000].xlsm"[/COLOR]

Try that.
 
Upvote 0
awesome yes with a bit of tweeking i have got it working, thank you so much :)

One more thing i need to include in it the year date in the title. but for last year. so at year end when i want the macro to run i need it to have "filename_yyyy" for the year before.

so & ThisWorkbook.Name & _yyyy<YYYY>.xlsm
 
Last edited:
Upvote 0
sorry i was being a noob, i got it now

Code:
ThisWorkbook.SaveCopyAs Filename:="C:\Users\" & Environ$("Username") & _
"\Desktop\" & ThisWorkbook.Name & "-" & Year(Date) & ".xlsm"

Thanks again alex, your a star, im sure ill be posting my next project lol

Adrac
 
Upvote 0

Forum statistics

Threads
1,216,488
Messages
6,130,952
Members
449,608
Latest member
jacobmudombe

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