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

Can you sort left to right?
To sort left-to-right, use the Sort dialog box. Click Options. Choose "Sort left to right"

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,353
Office Version
  1. 365
Platform
  1. Windows
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.
 

Lball

Board Regular
Joined
Oct 4, 2005
Messages
197
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?
 

Norie

Well-known Member
Joined
Apr 28, 2004
Messages
76,353
Office Version
  1. 365
Platform
  1. Windows
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
 

Forum statistics

Threads
1,175,847
Messages
5,899,813
Members
434,799
Latest member
Mussala

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