Pressing a button in another workbook

KlayColgrove

New Member
Joined
Oct 19, 2018
Messages
12
I am trying to use a macro that will open another workbook and press the button that is on the sheet "Instructions" then close the workbook after the task has been done. I have a list of name in column B so the action can be done on multiple worksheets. When I run my code is get the error: 400

Code:
Sub AllITMFTM()

Dim B As Range

For Each B In Range("B3", Cells(Rows.Count, "B").End(xlUp))
Workbooks.Open "D:\Documents\RM\Projects\New ITMFTM\" & B.Value & " ITMFTM Tool V1.3.xlsm"
Application.Run "'" & B.Value & "ITMFTM Tool V1.3.xlsm'!Instructions.CopyDataOver"
Workbooks(B.Value & "ITMFTM Tool V1.3.xlsm").Close SaveChanges = False
Next B

End Sub
 

Excel Facts

How can you turn a range sideways?
Copy the range. Select a blank cell. Right-click, Paste Special, then choose Transpose.
Put the "AllITMFTM" macro inside a module.
Check the name of the file, before " ITMFTM" there is a space.


Try this:


Code:
Sub AllITMFTM()
    Dim B As Range, wPath As String
    
    wPath = "D:\Documents\RM\Projects\New ITMFTM\"
    For Each B In Range("B3", Cells(Rows.Count, "B").End(xlUp))
        Workbooks.Open wPath & B.Value & [COLOR=#ff0000]" ITMFTM[/COLOR] Tool V1.3.xlsm"
        Application.Run "'" & B.Value & [COLOR=#ff0000]" ITMFTM[/COLOR] Tool V1.3.xlsm'![COLOR=#0000ff]CopyDataOver[/COLOR]"
        Workbooks(B.Value & [COLOR=#ff0000]" ITMFTM[/COLOR] Tool V1.3.xlsm").Close SaveChanges = False
    Next B
End Sub
 
Upvote 0
I'm glad to help you. Thanks for the feedback.
 
Upvote 0

Forum statistics

Threads
1,215,646
Messages
6,126,004
Members
449,279
Latest member
Faraz5023

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