Wikkles
06-22-2010, 08:44 AM
Hi everyone, I'm new here and relatively new to VBA coding but I was wondering if this is possible to do with VBA.
I have two workbooks that I use at work, one private: book2.xlsm and one public:book1.xlsm. I've written some code in the public book to help control the flow of things. What I'm basically trying to do is get VBA to (while book2 is the active window) move the mouse to a specific coordinate and left click on a button, then return to it's original position after the button is clicked.
Here's the code I'm working with (please excuse the sloppyness)
Sub PhoneyWork()
' PhoneyWork Macro
' Keyboard Shortcut: Ctrl+e
Range("A2:E2").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
Rows("1:1").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
Sheets("Sheet1").Select
Range("A2").Select
Selection.Copy
Windows("Book2.xlsm").Activate
Range("A3").Select
ActiveSheet.Paste
'Here is where I'd like to insert the mouse command
Windows("Book1.xlsm").Activate
Range("E2").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A2").Select
Selection.ClearContents
Windows("Book2.xlsm").Activate
End Sub
Any help would be appreciated! Thanks
I have two workbooks that I use at work, one private: book2.xlsm and one public:book1.xlsm. I've written some code in the public book to help control the flow of things. What I'm basically trying to do is get VBA to (while book2 is the active window) move the mouse to a specific coordinate and left click on a button, then return to it's original position after the button is clicked.
Here's the code I'm working with (please excuse the sloppyness)
Sub PhoneyWork()
' PhoneyWork Macro
' Keyboard Shortcut: Ctrl+e
Range("A2:E2").Select
Selection.Copy
Sheets("Sheet2").Select
ActiveSheet.Paste
Rows("1:1").Select
Application.CutCopyMode = False
Selection.Insert Shift:=xlDown, CopyOrigin:=xlFormatFromLeftOrAbove
Range("A1").Select
Sheets("Sheet1").Select
Range("A2").Select
Selection.Copy
Windows("Book2.xlsm").Activate
Range("A3").Select
ActiveSheet.Paste
'Here is where I'd like to insert the mouse command
Windows("Book1.xlsm").Activate
Range("E2").Select
Application.CutCopyMode = False
Selection.ClearContents
Range("A2").Select
Selection.ClearContents
Windows("Book2.xlsm").Activate
End Sub
Any help would be appreciated! Thanks