write code to "click" buttons

Lball

Board Regular
Joined
Oct 4, 2005
Messages
197
I have a simple macro that opens files, copies the page, then pastes in a master doc. After, it closes the file it copied from. It repeats this for 10 different files, opening, copying to master, then closing original. When i run the macro i get those messages asking if i want to save info to clipboard or save changes to original file. Is there a line of code i can put in to choose the "NO" in each of these cases. I'm assuming i'd have to put it in the macro at the corresponding point in the code for when it happens when running.

All help is appreciated!
 

Excel Facts

Which came first: VisiCalc or Lotus 1-2-3?
Dan Bricklin and Bob Frankston debuted VisiCalc in 1979 as a Visible Calculator. Lotus 1-2-3 debuted in the early 1980's, from Mitch Kapor.
Just put this at the start of the code.
Code:
Application.DisplayAlerts = False
And this at the end.
Code:
Application.DisplayAlerts = True
It might also help if you post your code - these messages might be able to be avoided rather than just suppressed.
 
Upvote 0
Here is a bit of the code. it was recorded. It goe on to open/copy 6 other worksheets as wel
Code:
'Open Ratesheet download
    ChDir "M:\Rate Sheet"
    Workbooks.Open Filename:="M:\Rate Sheet\ROSS RATES NEW DOWNLOAD ONLY.xls", _
        UpdateLinks:=0
    'Open Citi 2nds copy and paste then close
    ChDir "C:\Documents and Settings\lballa\Desktop"
    Workbooks.Open Filename:= _
        "C:\Documents and Settings\lballa\Desktop\Citi 2nd.xls"
    Cells.Select
    Selection.Copy
    Windows("ROSS RATES NEW DOWNLOAD ONLY.xls").Activate
    Sheets("Citi 2nd").Select
    Cells.Select
    ActiveSheet.Paste
    Windows("Citi 2nd.xls").Activate
    ActiveWindow.Close
    'Open Citi copy paste and close
    Workbooks.Open Filename:="C:\Documents and Settings\lballa\Desktop\Citi.xls"
    Cells.Select
    Selection.Copy
    Windows("ROSS RATES NEW DOWNLOAD ONLY.xls").Activate
    Sheets("Citi").Select
    ActiveSheet.Paste
    Windows("Citi.xls").Activate
    ActiveWindow.Close

THe "Master Doc" is password protected. Is there a way to put that in as well?
 
Upvote 0
Which sheet is the master?
Code:
Dim wbMast As Workbook
Dim wbOpen As Workbook
    Set wbMast = Workbooks.Open(Filename:="M:\Rate Sheet\ROSS RATES NEW DOWNLOAD ONLY.xls")
        
    'Open Citi 2nds copy and paste then close

    Set wbOpen = Workbooks.Open(Filename:="C:\Documents and Settings\lballa\Desktop\Citi 2nd.xls")
    wbOpen.ActiveSheet.Cells.Copy wbMast.Sheets("Citi 2nd").Range("A1")
    wbOpen.Close
    
    'Open Citi copy paste and close
    Set wbOpen = Workbooks.Open(Filename:="C:\Documents and Settings\lballa\Desktop\Citi.xls")
    wbOpen.ActiveSheet.Cells.Copy wbMast.Sheets("Citi").Range("A1")
    wbOpen.Close
 
Upvote 0

Forum statistics

Threads
1,214,584
Messages
6,120,387
Members
448,956
Latest member
JPav

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