Results 1 to 6 of 6
  1. #1
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Activate application (Word 2003)

    I've written a VB application that is launched by the user in Outlook. The VB application creates a data file based on the selected Contacts. I minimized the Outlook window, get the Word application, activate Word, and then my VB app launches a Word macro where the user will choose what to do with the data that was just written to file.

    I'm not succeeding in having Word get focus. If the macro I launch in Word displays a dialog, the dialog displays as expected, but the caption is grey, indicating that it does not have focus. The active document's title bar is also great. The Word task on the Windows task bar is flashing. The document -- indeed the Word application -- does seem to get focus until I click on the document or the (custom) dialog.

    If I don't display a dialog and instead type text in the active document, the text is added, but the document still is not "ready" for the user to type. A click of the mouse is required first. Is there a way to avoid this? I don't consider this to be a burden, but I know that users will find it to be a great inconvenience.

    Thanks,
    Richard

  2. #2
    Silver Lounger
    Join Date
    Jul 2001
    Location
    Ottawa, Ontario, Canada
    Posts
    1,609
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Activate application (Word 2003)

    Can you post the Word macro up to and including the decision point where the user will choose what to do with the data that was just written to file?
    Regards
    Don

  3. #3
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Activate application (Word 2003)

    Thanks. The code is below. I've got a msgbox here, which also does not have focus until cllicked. I've tried commenting out the msgbox line and using the two lines which are currently commented out below, and I have the same results. The document, with or without the msgbox/dialog is "on top", but does not really have focus. The Word item in the task tray flashes until I click.

    The last line of code in my VB app launches the macro. The previous line is Word.Application.Activate.

    Sub RBTest()
    Application.Activate
    DoEvents

    If Documents.Count = 0 Then
    Documents.Add
    End If

    'ActiveDocument.Range(0, 0).Select
    'Selection.TypeText "Test"
    MsgBox "RB Test has launched."
    End Sub

    Thanks,
    Richard

  4. #4
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Activate application (Word 2003)

    I wonder if this is specific to Word 2003. I've tried this with another user (also Word 2003), and the situation is the same.

    If I move this to a PC with Office 2007, I have no problem. Word is activated and has focus as I would expect it to.

  5. #5
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Activate application (Word 2003)

    Does it work better if you use

    AppActivate "Microsoft Word"

  6. #6
    5 Star Lounger
    Join Date
    Mar 2001
    Location
    New York, NY
    Posts
    922
    Thanks
    2
    Thanked 12 Times in 11 Posts

    Re: Activate application (Word 2003)

    Yes! Thank you very much.

    Regards,
    Richard

Posting Permissions

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