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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Word document event onfocus/activate

Status
Not open for further replies.

BrianWen

Programmer
Jun 8, 2009
102
DK
Can it really be true, that there is no way to catch whenever a certain already opened document gets focus/is activated?
I want to run a small bit of code whenever certain documents gets focus.
 
Have you tried using the ActiveDocument property in Word VBA?

For instance, you could use that property, and something..
Code:
With ActiveDocument
  If .Name = "MySpecialDocument" Then
    'Do whatever you wanna do
  End If
End With

Then run that code perhaps from a timer, or search for any "on refresh" or "on gotfocus" or something along those lines.
 
By the way, if you're looking for a solution specific to Word, which it sounds like, that needs to be asked in the MS Office thread (if not VBA-related) or in the Office VBA forum if it relates to using code for MS Word. This is where I think you want to go with it:
forum707
 
Thanks for answering. And oops for creating the topic the wrong place. I accessed a previously asked question (apperantly an Access question) and just hit the New Thread button, assumin I was in VBA, where I usually hang out. Sorry!
 
Oh, it's no problem. I've done similar before myself - forgot which forum I was in before posting or replying. [wink]
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top