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
 

Some videos you may like

Excel Facts

How to show all formulas in Excel?
Press Ctrl+` to show all formulas. Press it again to toggle back to numbers. The grave accent is often under the tilde on US keyboards.

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
 

Subscribe on YouTube

Watch MrExcel Video

Forum statistics

Threads
1,106,720
Messages
5,513,015
Members
408,932
Latest member
sbafw

This Week's Hot Topics

  • Sort code advice please
    Hi, I have the code below which im trying to edit but getting a little stuck. This was the original code which worked fine,columns A-F would sort...
  • SUMPRODUCT with nested If statement
    Hi everyone, Hope you're all well. I'm hoping someone will be able to point me in the right direction with a problem I'm having with a SUMPRODUCT...
  • VBA - simple sort is killing me!
    Hello all! This should be so easy, but not for me, apparently! I have a table of data that can be of varying lengths and widths. My current macro...
  • Compare Two Lists
    I have two Lists and I need to be able to Identify differences between them. List 100 comes from a workbook - the other is downloaded form the...
  • Formula that deducts points for each code I input.
    I am trying to create a formula that will have each student in my class start at 100 points and then for each code that I enter (PP for Poor...
  • Conditional formatting formula required for day of week and a value
    Hi, I have a really simple spreadsheet where column A is the date, column B is the activity total shown as a number and column C states the day of...
Top