Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- Set xlApp =GetObject("C:MATRIKSUSERREPORTSEXCELTemp.xls").Application
- Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
- Public Declare PtrSafe Sub mouse_event Lib "user32" (ByVal dwFlags As Long, ByVal dx As Long, ByVal dy As Long, ByVal cButtons As Long, ByVal dwExtraInfo As Long)
- Public Const MOUSEEVENTF_LEFTDOWN = &H2
- Public Const MOUSEEVENTF_LEFTUP = &H4
- Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
- Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
- Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
- Sub MainSequence()
- 'This sub pieces together MatriksFlowUpdate and CloseInstance
- Call MatriksFlowUpdate
- Sleep 2000
- Call CloseInstance
- End Sub
- Sub MatriksFlowUpdate()
- 'Prompts 3rd party software (Matriks) to produce Excel with latest flow data
- Call RightClick
- Call SingleClick
- End Sub
- Private Sub RightClick()
- 'Simulates a mouse right click at desired screen coordinates
- Sleep 1000
- SetCursorPos 1750, 750 'x and y position
- mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
- mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
- End Sub
- Private Sub SingleClick()
- 'Simulates a mouse left click at desired screen coordinates
- Sleep 1000
- SetCursorPos 1750, 650 'x and y position
- mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
- mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
- End Sub
- Sub CloseInstance()
- 'Finds the instance of Excel where Matriks exported its excel and closes that instance of Excel
- Dim xlApp As Excel.Application
- Dim WB As Workbook
- Set xlApp =GetObject("C:MATRIKSUSERREPORTSEXCELTemp.xls").Application
- Set WB = xlApp.Workbooks("Temp.xls")
- WB.Close
- End Sub
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement