Save a File to a Specific location Using a Macro in Excel



Save a File Using a Macro in Excel, Save a file to a particular location using a macro. Save a file as a particular type using a macro. Check out my online courses
Become an Affiliate and earn 25% on Course Sales

For more help visit my website or email me at easyexcelanswers@gmail.com.

code
Private Sub CommandButton1_Click()
Dim path As String
Dim filename1 As String

path = “C:UsersBarbDesktopdemo”

filename1 = Range(“C4”)
Application.DisplayAlerts = False
ActiveWorkbook.SaveAs Filename:=path & filename1 & “.xlsx”, FileFormat:=xlOpenXMLWorkbookFileFormat:=xlOpenXMLWorkbook

FileFormat:=xlOpenXMLWorkbook
Application.DisplayAlerts = True
Activeworkbook.close

End Sub

For more help visit my website or email me at easyexcelanswers@gmail.com.

Contact me regarding customizing this template for your needs.

Excel one-on-one on-line training available. Email me to arrange.

I am able to provide online help on your computer at a reasonable rate.

Check out my next one-hour Excel Webinar

I use a Blue condensor Microphone to record my videos, here is the link

Check out Crowdcast for creating your webinars

If you need to buy Office 2019 follow

I use Tube Buddy to help promote my videos
Check them out

Follow me on Facebook

TWEET THIS VIDEO

Follow me on twitter
easyexcelanswers

IG @barbhendersonconsulting

You can help and generate a translation to you own language

*this description may contain affiliate links. When you click them, I may receive a small commission at no extra cost to you. I only recommend products and services that I’ve used or have experience with.

Watch more new videos about Excel Office | Synthesized by Mindovermetal English

Rate this post

Bài viết liên quan

Theo dõi
Thông báo của
guest
48 Comments
Cũ nhất
Mới nhất Được bỏ phiếu nhiều nhất
Phản hồi nội tuyến
Xem tất cả bình luận
Brody Harrison

Thank you! The key for me was adding the .txt after the file name.

wai zhenyi

is there a way to save the specific worksheet instead of the whole workbook itself?

Wasif Abbas

Main issue remains the same as user can't give the file path. Idea is that as macro run, box appears & ask user to specify the path where want to save the file while in this video, path is being fixed while it need to be user defined. If, you know how to address the issue, kindly let me know like through dialogue box but that point to file opening.

Nabil El Mokhliss

Hi Barb
Thank you again for streamlining information
I need to do something similar I'm not sure if it is possible to do
Saving a .docx file instead with a specified name (file name=cell value)
A trillion thanks

Jonny Brown

You've made my year. Thank you!

Govind Choudhari

That's great…
It works perfectly but the only thing is I also want to break all the links after save as the file. Is it possible ?

Hrvoje Rožan

which is the code for the word document?

Very useful thanks. When I use this code it's work properly. but my saved macro file macros is not working. what kind of changes need to that. Kindly replay as soon as possible.

Wellington Moreira

Tks!

Jaqueline Assis

Hi Barb! I've played with your teachings but I couldn't figure out a way to combine them. I'd like to have a master PO file that increases the number by 1 when I open it, then, after I input the data, I'd like to have a button to save the workbook to a specific location, then clear the contents of the master PO and have it ready for next time. Any way to do it?

Hemant Kulharia

Nice tutorial. But if I want to copy a diff extension file from an folder to pendrive inserted how can I do that can you help?

Fresh Muzik

In a same way how to create a folder?

Brendon Cafferkey

How can I have the file revert to the original file after hitting the save button?

Abdul Razak

Thank you so much

Charlemagne Losaria

you deserve more subs!

George Aloyce

Nice video but to bad when i close my excel and reopen the button disappears, help me

Zjenster Logic

Thank You lady!!!
This is the one I've been looking for!

Neelam Modgil

this not work in win 10 64 bit

Kiran karthikeyan

Thank you .

Luke Martin

Are you able to export an Excel sheet to save as a XML file via macro?

I have a macro for copying and pasting data from one sheet into another sheet where I have columns that are XML Sourced set up how an application I'm using will accept them. I currently run the macro to copy and paste one batch of records at a time into the sheet then have to hit Export and name the files (1, 2, 3 etc.). My macro removes the batch of entries and copies in the next set. If a macro could export and name the file the next number in sequence that would be great.

Waseem Limbaliya

What if Madam !!!! if i want to save a file into sub folder of Active workbook path as pdf. I dont care where the file is being saved , the macro should save the file where the active workbook located and make subfolder. For example Macro Enabled Workbook is Saved into C:My FolderVouchers.xlsm. Now i want to save a PDF file into C:My FolderPayment VoucherVoucher_001.pdf without giving the address. just want to save where the activeworkbook is being saved. please madam guide me.

Alisa Zahra

Hi mam. I have a question.. how to save as workbook from another workbook.

Thair Rasool

thank you for the efforts it was very clear example

Mussa TV

Excellent
I have some issues kindly help me to resolve
1: how can i save the new file without micro without micro button

Mah Martins

What if the paths are from a list that you need to loop from? Different files names into different paths that will loop from a list?

H Asmawiah

its amazing mam.. i have a question, how to save as the sheet that we want, for example i want to save sheet 1 and sheet 6.. thaks mam, i really need your help

PDKB UPT Cilegon

how to save as file with format macro… please

Richard Lau

Hi there, may i know how can i name the file name as A1(name) + B1(date)?

Ümit Doymaz

Thanks a lot Barbara for this video. I used it. perfect lob.

Ashwin D

Hi Barb,

I have used the same code as u mentioned, however the code / step for Saveas is getting debugged. Can you please advise why

Anuj Kaushal

Hello Barb
Video is really helpful..thanks for sharing it.
Can you please share the code if the file in the designated path is already there…how to display the option to save it again with different name???
Pls help me with this.
Thanks

Mohammad Yawar

Great. Thanks for making this video, very helpful. But I don't want to close the active workbook after saving the file. Can anyone please help me out?

Ricardo Mendez

Hi Barb, How can I make it save to an FTP location?

Nitin Rao

can you please copy paste this code

Aasa Stephenson

Awesome breakdown! You should be a teacher! Nice video!😀

mf675913

Just noticed that the coding in description section is missing the term ".Text" from line "filename1 = Range("C4")" and two extra pasted in text "FileFormat:=xlOpenXMLWorkbook"

Aryan Singh

Thanks

Mohan Chalageri

I need your guidance here to copy the latest file in a folder and paste it in another path. Can you please help me on this..

Assad MK

thank you so much,it helped me alot…

ivan pap

Really helpful and interesting! Is it possible to save in 2 differents path according to a specific cell value (path1 or path2)?

Pritam Mokashe

mere isme error aa raha hai

KRISHNA JAGADEESH

I am your subscriber I support your channel thank you

KRISHNA JAGADEESH

Super madam very nice bt I need agine one more question how to automatically open file my friend send one excel file to email me download then use hear save to pdf button have me click the button automatically open this workbook location one ( pdf folder) open then inside this pdf file have when I delete this pdf Fila not possible this he how to make please explain madam

Rollotollo100

Hi. What do I need to change in this code that the original excel stays active? Right now it automatically opens the saved excel and I dont want it to become active. I mean if I want to continue editing the original excel file.

Lucky Mane

Hi Barb just joined to your channel please also make video on power bi eagerly waiting for power bi series video

Faiz Raut

Thank you so much, it was easy to understand and implement

Amar Kardile

Madam how to capy sheet2 in specific folder and path with cells name using userform..??

Alan McGibbon

I really like how straightforward this is. So much so that I’ve subscribed for more. However I have a problem with the macro. When I run it I finish up with a line highlighted in yellow. The line in question starts “ActiveWorkbook.SaveAs” and the message on screen is “Run-time error ‘1004’ Method ‘SaveAs’ of object ‘_Workbook’ failed. I am using Excel 2016. Can I please have a solution as the macro is perfect for the sheet I’m preparing.