473,396 Members | 2,087 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,396 software developers and data experts.

Mouse Click Flush

Good Morning,

I need to develop a macro on Excell(VBA) that eventually will send multiple mouseclicks and work on the selected cells. Since the sheet it will work on doensn't have a recursive pattern to work but the screen itself, mouse clicks seems to be the way.

I've browsed for information about moving the mouse cursor in VBA and it works, however the mouseclick I found only clicks on the end of the macro run, as if it was the last command of the macro.

I'm using these API's and Excell 2007

Expand|Select|Wrap|Line Numbers
  1. Declare Function SetCursorPos Lib "user32" (ByVal x As Long, ByVal y As Long) As Long
  2.  
  3. Declare Function mouse_event Lib "user32.dll" (ByVal dwflags As Integer, ByVal dx As Integer, ByVal dy As Integer, ByVal dwData As Integer, ByVal dwExtraInfo As Integer) As Integer
Is there a way to fix this issue?

All clicks resume to just a single click in the end of the macro.
Dec 30 '10 #1
1 1873
Stewart Ross
2,545 Expert Mod 2GB
Hi. Before getting to grips with the issue of mouse clicks, could you let us know why you need them?

There is in general no requirement in VBA to physically select a cell by clicking on it before doing something with it. Even if there was there is a Select statement which is available for this purpose - you will see it used a lot if you examine code generated by the macro recorder in Excel.

In VBA, cells are referenced as worksheet range objects. It is possible to do almost anything at all to any cell in any worksheet without the use of a mouse click - for example, it is possible to add a formula to a cell, set its background colour, set its formatting and so on without doing anything other than referring to the appropriate cell range directly, like this:

Expand|Select|Wrap|Line Numbers
  1. With ActiveSheet.Cells(1, 1)
  2.   .Font.Bold = True
  3.   .Formula = "=Sum(A2:A100)"
  4.   .interior.colorindex = 34
  5. End With
Not sure why whether or not a routine is recursive would mean using mouse clicks, but perhaps you could expand a little on what it is you need to do so we can guide you better?

-Stewart
Dec 30 '10 #2

Sign in to post your reply or Sign up for a free account.

Similar topics

10
by: BadOmen | last post by:
I want my program to send a mouse click to the window at the current mouse position, how do I do that? Example: I have my mouse over a button in Word and then my program is sending the left...
2
by: Serge | last post by:
Hi, in my windows.forms application I have added a goupBox control to my windows.form. Now I want to know the x,y-position from the mouse cursor when I click on the groupBox. The strange thing...
12
by: mdb | last post by:
My app has a notify icon in the systray. I want the left mouse click to initiate a menu, and a right-mouse click to do something else. Normally, for a button, I would listen to MouseDown and if I...
4
by: Prateek | last post by:
Hi All, I have created an ASP.NET page that basically consists of a table having text boxes in all cells. The table is created using client side java script. There are some calculations being...
4
by: aam | last post by:
i'm trying to find the coordinates of a certain button on a page that i'm viewing so i can program the mouse to click on it automatically every so many seconds. either that or have the mouse click...
24
by: aam | last post by:
hi, im trying to figure out how i can program the mouse to automatically click on a button of a web page that i'm viewing.i do not have control over the page.i would also like to set up an...
3
by: Gary Kahrau | last post by:
How do I programatically apply a click to a particular row and column 0 of a datagrid? I want to do this in code as if the user did a mouse click on the leftmost column. ...
4
by: Abhishek | last post by:
Hi, I have a activex web browser embedded in a windows form and on a click of a form button i need the mouse to go the position for example 100, 100 and click the link that will be there on that...
5
by: moonie | last post by:
I have an msn style c# windows application with a form and panel on it. A news list is drawn from the database and dynamically added via labels, link lables during form loading. In this...
1
by: hamidnourashraf | last post by:
I'm wondering if it's possible to invoke a mouse click anywhere. I don't mean invoke a mouse click event but, the actual mouse click itself. For instance, If I had my mouse over the "my computer"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.