Save XLS file without opening

axelg

New Member
Joined
Jan 21, 2016
Messages
42
Office Version
  1. 365
Platform
  1. Windows
When I run my script, at the end I have

ActiveWorkbook.SaveAs Filename:=path & fnameBLT, FileFormat:=51

To save the file to a new xls file. (its in fact sheets hidden, specific sheets actiive and with protection. This to pass on to someone)

All seems to work, file is written as I want, only issue I'm facing is following.

My file is now called MYFILENAME.xlsx ... when I run the above this file I'm working in gets renamed to the new dynamic naming in the above (so NEWNAMING.xls.
The fact that it gets a new name and saves that is ok, that's what I wanted, but it also opens . That means that MYFILENAME.xlsx is closed/no longer visible and the NEWNAMING.xls is now visible.
Is there a way to set it that this only runs in the background without opening the file?
 

Excel Facts

Format cells as date
Select range and press Ctrl+Shift+3 to format cells as date. (Shift 3 is the # sign which sort of looks like a small calendar).
Are you thinking of SaveCopyAs ?

VBA Code:
Workbooks(“Your Workbook Name”).SaveCopyAs(
 
Upvote 0
Solution
Just note that you can't use SaveCopyAs if you are changing format. It's not clear from your post if that's the case here, but I thought I'd mention it.
 
Upvote 0
Just note that you can't use SaveCopyAs if you are changing format. It's not clear from your post if that's the case here, but I thought I'd mention it.
Thanks, that is indeed something I'm running into

ActiveWorkbook.SaveAs Filename:=path & fnameBLT, FileFormat:=51 Works Fine (but not what I Want)
ActiveWorkbook.SaveCopyAs Filename:=path & fnameBLT, FileFormat:=51 Gives an error probably as original file type is xlsm.

Do you have a genius way to solve that :)
 
Upvote 0
You could copy all the sheets to a new workbook, and then save that. Or use SaveCopyAs, open the copy and save it in the desired format, then close it again.
 
Upvote 0
d copy all the sheets to a new workbook, and then save that. Or use SaveCopyAs, open the copy and save it in the desired format, then close it again.
Ok, thanks the info.
 
Upvote 0

Forum statistics

Threads
1,214,987
Messages
6,122,618
Members
449,092
Latest member
amyap

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