vba code that I can assign to a Button in Toolbar

ryannnn_stl

New Member
Joined
Jun 30, 2009
Messages
9
I can't figure this one out and I would appreciate some help.

What I'm trying to do...
I download an excel file from an external website like 5 times a day. I want to have a custom button, in my toolbar, that takes the activeworkbook and saves the file as a specific file name, then closes the file.

Process...
On the website I click, "Download to Excel," and and excel file pops up automatically. (The file name that gets downloaded is always different, depending on the time and date. example: "0805101355.xls") I then have to click file, save as and navigate to a specific file. (THe file that I save to is always the same, "daily_sales.xls") I save as and then close the work book.
^ I want a permanant button, that always opens with excel, that does this automatically

I have a feeling this is an easy fix. I just can't figure out how to do it. I think the problem is I don't know where to put this code. I tried putting the code in the daily_sales.xls file, but it wouldn't close the original Let me know if I need to clarify anything. Thanks for the help! Ryan

Code:
Sub sales_save()
 
Application.DisplayAlerts = False
 
Dim name As String, name1 As String
 
name = ThisWorkbook.name
name1 = "daily_sales.xls"
 
Windows(name).Activate
    ThisWorkbook.SaveAs Filename:= _
        "C:/daily_sales.xls", _
        FileFormat:=xlNormal, Password:="", WriteResPassword:="", _
        ReadOnlyRecommended:=False, CreateBackup:=False
 
    Windows(name1).Activate
    ActiveWindow.Close
 
 
End Sub
 

Excel Facts

Excel motto
Not everything I do at work revolves around Excel. Only the fun parts.

ryannnn_stl

New Member
Joined
Jun 30, 2009
Messages
9
Thanks for the Idea MisterCrash! Never worked with add-ins before. At the moment, it seems like that did the trick! Thanks for the help and the link! Ryan
 
Master Excel Bundle

Excel contains over 450 functions, with more added every year. That’s a huge number, so where should you start? Right here with this bundle.

Forum statistics

Threads
1,163,398
Messages
5,831,404
Members
430,064
Latest member
Shahrukh kha

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
Top