how to simulate mouse button press via VBA

Excelina

New Member
Joined
Mar 23, 2002
Messages
3
hi all,
i have a workbook that opens an other workbook by macro. i have a little mousepointer problem cause the mousepointer in the workbook opened by macro kind of jams and i need to press the right mouse button once in order to make it work normally. my question is how would i simulate this right mouse button pressing by VB code? could sendkey statement or something like that be used here?

sorry for this oversized post, but that´s the way i am
 

Excel Facts

Excel Joke
Why can't spreadsheets drive cars? They crash too often!
I have the same exact problem, miss Excelina! I was wondering about that SendKeys thing too, posted a question here, didn't get any answers...

Every time I saw a MVP or punch of Masters logged in, I put my post up again, but that didn't help, they locked my post! Those bastards! ; )

Anyways, I really hope somebody takes you seriously and gives us something to work with, even simple "Don't go there" for that SendKeys statement would do, at least we could stop jerking around with it...
 
Upvote 0
Hi,

Do you want to make a Right Click on the document?

If so just call RightDown sub wherever you need.

Private 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)
Const MOUSEEVENTF_RIGHTDOWN = &H8
Const MOUSEEVENTF_RIGHTUP = &H10

Public Sub RightDown()
mouse_event MOUSEEVENTF_RIGHTDOWN, 0, 0, 0, 0
mouse_event MOUSEEVENTF_RIGHTUP, 0, 0, 0, 0
End Sub

regards
 
Upvote 0
Hi Sbirro Cornuto,

Actually i'd like to see your code to find possible solution to avoid it without using right click.

It is nice to hear that it works for you.
 
Upvote 0
Don't worry Dave, I don't see how you could ever sound smart.

Here's little explanation for you wiseasses:

There is nothing wrong with my mouse or with Excelina's (I'm guessing). I just need to automate that Mouse Button event, cause I have few workbooks opening each other through VBA and VB code and there is a lot of Cursor playing in there also, mostly with ani-files. The Cursor changes however wont work everytime without a right click from the mouse and since this is all suppose to be done automaticly I need to automate that mouse click in there, too.

I hope this is all right with you, Dave. And I must warn you that I might ask something else concerning Excel automation in this forum in the future, so if I'm in someway bothering you, feel free to skip my topics...
 
Upvote 0
On 2002-03-26 06:00, smozgur wrote:
Hi Sbirro Cornuto,

Actually i'd like to see your code to find possible solution to avoid it without using right click.

It is nice to hear that it works for you.

Thanks for the offer smozgur, but your code really works all right and I don't want to make so many changes to the ani-file loading procedures to avoid this MousePointer jamming, so relax and take the pleasure of knowing that you really have helped a lot. You are awesome!
 
Upvote 0

Forum statistics

Threads
1,213,496
Messages
6,113,993
Members
448,539
Latest member
alex78

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top