Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default how to move mouse using excel macro

hi, i need a macro to move mouse pointer and simulate mouse click to access
activate a report. sendkey dont work as to run the report will require a
mouse buttom click.
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default how to move mouse using excel macro

Hi William

To control the mouse using code try the below. You will need to adjust the
cursor positions to suit your requirement. (in the below example it is
150,200) . Try and feedback.


--Insert a module and copy the below declarations.
'---------------------------------------------------------------------------------
Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long
Public Declare 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 Declare Function GetMessageExtraInfo Lib "user32" () As Long
'---------------------------------------------------------------------------------

--Copy the below code to the macro

Private Sub Macro()
'your other code

SetCursorPos 150, 200
mouse_event &H2, 0, 0, 0, GetMessageExtraInfo()
mouse_event &H4, 0, 0, 0, GetMessageExtraInfo()
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"William Yeow" wrote:

hi, i need a macro to move mouse pointer and simulate mouse click to access
activate a report. sendkey dont work as to run the report will require a
mouse buttom click.

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8,520
Default how to move mouse using excel macro

In the mean while I assume you already know about AppActivate Function which
activates an application that is already running.

http://msdn.microsoft.com/en-us/libr...hy(VS.80).aspx

If this post helps click Yes
---------------
Jacob Skaria


"Jacob Skaria" wrote:

Hi William

To control the mouse using code try the below. You will need to adjust the
cursor positions to suit your requirement. (in the below example it is
150,200) . Try and feedback.


--Insert a module and copy the below declarations.
'---------------------------------------------------------------------------------
Declare Function SetCursorPos Lib "user32" _
(ByVal x As Long, ByVal y As Long) As Long
Public Declare 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 Declare Function GetMessageExtraInfo Lib "user32" () As Long
'---------------------------------------------------------------------------------

--Copy the below code to the macro

Private Sub Macro()
'your other code

SetCursorPos 150, 200
mouse_event &H2, 0, 0, 0, GetMessageExtraInfo()
mouse_event &H4, 0, 0, 0, GetMessageExtraInfo()
End Sub


If this post helps click Yes
---------------
Jacob Skaria


"William Yeow" wrote:

hi, i need a macro to move mouse pointer and simulate mouse click to access
activate a report. sendkey dont work as to run the report will require a
mouse buttom click.

Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel 2007: mouse cant find cell handle to drag/move Carl Henthorn Excel Discussion (Misc queries) 4 April 30th 23 03:44 AM
Mouse Move K[_2_] Excel Programming 0 December 11th 08 11:32 AM
Highlight 1 cell in Excel & move mouse-stays highlighted - stop? Patriot Excel Discussion (Misc queries) 2 January 16th 06 10:49 PM
control-tab should move between Excel sheets without a mouse. SpecialK Excel Worksheet Functions 2 July 7th 05 08:45 PM
move mouse or cursorpos BrianB Excel Programming 0 January 21st 04 03:56 PM


All times are GMT +1. The time now is 02:28 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"