none
How to set the focus on a Word Windows from Access? RRS feed

  • Question

  • Hi,

        the user of my Access (2007 or 2010) database is able to create a Word (2007 or 2010) document selecting some controls in a form and then clicking on a button.

        My code is able to get/create a Word instance, to create a new document based on a template, and to call a procedure stored in my Word template.

       Everything seems fine, but the focus remains on Access, the Word icon is only blinking on the taskbar, whereas I would like to have the new Word window in foreground. On other occasions I would like to have in foreground not a new Word window but one already open.

       I tried Windows(NameOfWordFile).Activate inside a Word procedure called in the last line of my Access code or objWordApp.Activate from my Access code, but without success.

    Do you have any suggestions?

    thanks, Lauro

     

    Thursday, September 27, 2012 7:53 PM

Answers

  • Hi Lauro

    I assume you're opening or adding a document as part of this process and setting that to a document object? Something like:

      Set doc = wdApp.Documents.Add

    Then try: doc.Activate


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 28, 2012 5:14 AM
    Moderator

All replies

  • Hi Lauro

    I assume you're opening or adding a document as part of this process and setting that to a document object? Something like:

      Set doc = wdApp.Documents.Add

    Then try: doc.Activate


    Cindy Meister, VSTO/Word MVP, my blog

    Friday, September 28, 2012 5:14 AM
    Moderator
  • Hi Cindy,

       sorry I didn't YET say you "thanks" for your answear.

       I say it now: Thank you.

    Lauro

    Monday, October 8, 2012 2:04 PM