SHARE
TWEET

Untitled

a guest Jun 16th, 2019 66 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. Set xlApp =GetObject("C:MATRIKSUSERREPORTSEXCELTemp.xls").Application
  2.      
  3. Public Declare PtrSafe Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
  4.     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)
  5.     Public Const MOUSEEVENTF_LEFTDOWN = &H2
  6.     Public Const MOUSEEVENTF_LEFTUP = &H4
  7.     Public Const MOUSEEVENTF_RIGHTDOWN As Long = &H8
  8.     Public Const MOUSEEVENTF_RIGHTUP As Long = &H10
  9.     Public Declare PtrSafe Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As LongPtr)
  10.  
  11.     Sub MainSequence()
  12.         'This sub pieces together MatriksFlowUpdate and CloseInstance
  13.         Call MatriksFlowUpdate                                        
  14.         Sleep 2000
  15.         Call CloseInstance
  16.         End Sub                                                        
  17.  
  18.     Sub MatriksFlowUpdate()
  19.         'Prompts 3rd party software (Matriks) to produce Excel with latest flow data
  20.         Call RightClick
  21.         Call SingleClick
  22.         End Sub
  23.  
  24.     Private Sub RightClick()
  25.     'Simulates a mouse right click at desired screen coordinates
  26.     Sleep 1000
  27.     SetCursorPos 1750, 750 'x and y position
  28.     mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
  29.     mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
  30.     End Sub
  31.  
  32.     Private Sub SingleClick()
  33.     'Simulates a mouse left click at desired screen coordinates
  34.     Sleep 1000
  35.     SetCursorPos 1750, 650 'x and y position
  36.     mouse_event MOUSEEVENTF_LEFTDOWN, 0, 0, 0, 0
  37.     mouse_event MOUSEEVENTF_LEFTUP, 0, 0, 0, 0
  38.     End Sub
  39.  
  40.     Sub CloseInstance()
  41.     'Finds the instance of Excel where Matriks exported its excel and closes that instance of Excel
  42.     Dim xlApp As Excel.Application
  43.     Dim WB As Workbook
  44.     Set xlApp =GetObject("C:MATRIKSUSERREPORTSEXCELTemp.xls").Application
  45.     Set WB = xlApp.Workbooks("Temp.xls")
  46.     WB.Close
  47.     End Sub
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top