Results 1 to 2 of 2
  1. #1
    Gold Lounger
    Join Date
    Dec 2000
    Location
    Hollywood (sorta), California, USA
    Posts
    2,759
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Setfocus v. Activate (Word 2002)

    Do these statements do the same thing, or are there some subtle differences
    of which to take note?:

    Application.ActiveWindow.SetFocus
    Application.Activate

    I'm trying to make sure that the very next statement

    hWnd=GetActiveWindow()

    returns the Word application window handle.

    In some cases another app may take focus when Word starts up. I'm having a bit
    of difficulty getting the Word app window handle EVERY time Word starts.

    p.s. I've tried using hWnd = FindWindow("OpusApp",vbNullString), but that's even less
    reliable. Apparently, Word needs to "settle" a bit before the API can find it's main form handle.
    Kevin <IMG SRC=http://www.wopr.com/w3tuserpics/Kevin_sig.gif alt="Keep the change, ya filthy animal...">
    <img src=/w3timages/blackline.gif width=33% height=2><img src=/w3timages/redline.gif width=33% height=2><img src=/w3timages/blackline.gif width=33% height=2>

  2. #2
    5 Star Lounger
    Join Date
    Jul 2002
    Location
    Toronto, Ontario, Canada
    Posts
    1,139
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Setfocus v. Activate (Word 2002)

    Kevin,

    Application.Activate will activate the Word application

    Application.ActiveWindow.SetFocus should just set the focus to the active document in Word, but maybe not make it the "active" application.

    If you are trying to get the handle for Word, I'd think that Application.Activate will be your best bet.
    --
    Bryan Carbonnell - Toronto <img src=/S/flags/Ontario.gif border=0 alt=Ontario width=30 height=18> <img src=/S/flags/Canada.gif border=0 alt=Canada width=30 height=18>
    Unfortunately common sense isn't so common!!
    Visit my website for useful Word, Excel and Access code, templates and Add-Ins

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •