Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

MSword: running a macro on a right mouse click

Status
Not open for further replies.

kkny3

Technical User
Jun 9, 2007
5
0
0
VN
I've already posted this to the office forum and was told that it was a VBA question so here it is again....


I am an artist trying to create an interactive piece using a macro. I want to run a macro in Word on right mouse click. It doesn't matter what the mouse is over. Is this possible and what are the commands?

Unfortunately, the help for macros has not been installed on my manchine and on top of that I am traveling in Asia. Hmmm.... and my internet access is sketchy how many obstactles can one have? Don't answer that... merely a rhetorical question, but please do answer the one about the right click.

Thanks
 




Hi,

MS Word has no mouse-related events.

However, you might consider inserting a Control Toolbox Image control. Format the control Layout BEHIND the text, and make the size, the dimensions of each page. This control has mouse events.

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
And get Help installed!
I want to run a macro in Word on right mouse click. It doesn't matter what the mouse is over.
Why? Skip is correct that controls have mouse events, but they are tied to the control, so the "doesn't matter what the mouse is over"...DOES matter.

Perhaps if you explained a bit more what you are trying to achieve.

faq219-2884

Gerry
My paintings and sculpture
 
Actually, you can use word application object to trap right-click event. However, there is a long way to create word application. As a starter, try (ThisDocument module):
Code:
Public WithEvents wdApp As Word.Application

Private Sub Document_Close()
Set wdApp = Nothing
End Sub

Private Sub Document_Open()
Set wdApp = Application
End Sub

Private Sub wdApp_WindowBeforeRightClick(ByVal Sel As Selection, Cancel As Boolean)
Cancel = True
MsgBox Sel.Text
End Sub

combo
 
SkipVought,

I have a follow-up question. If I use the control you recommended then use select all/delete will this control also be deleted?

Thanks for your help.
 



That should be an easy question to answer yourself. Did you conduct a test to see what happens?

Skip,
[sub]
[glasses] [red][/red]
[tongue][/sub]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top