none
How to activate Office applications through automation in Windows 7? RRS feed

  • Question

  • Automating Office applications from VFP 9.0 in Windows Vista, the following code fragments make the Office app visible and active, but in Windows 7 the Superbar (Windows 7's taskbar) pops up with the Office app's button blinking; the app does not become visible or active.

    *--- For PDFs and HTMs
    lo = GetObject("", "InternetExplorer.Application")
    lo.Visible = .T.
    lo.Navigate(lcFilename)

    *--- For DOCs, DOCXs, DOCMs, and RTFs
    LOCAL loWord
    loWord = CREATEOBJECT("Word.Application")
    IF TYPE("loWord")="O"
       lo = loWord.Documents.Open(lcFilename)
       loWord.Visible = .T.
       loWord.Activate()
    ENDIF

    *--- For XLSs and XLSXs
    lo = GETOBJECT(lcFilename)
    lo.Application.Visible = .T.
    lo.Windows[1].Activate()

    In Windows 7, how does one make Office applications opened through automation visible and active?

    Thursday, March 3, 2011 1:15 AM

Answers

  • Hello BinaryBob,

    Thanks for posting. Actually, I have used VBA code below to create a new Word application and make it visible.

    Sub test()
        Set wordApp = CreateObject("Word.Application")
        wordApp.Visible = True
    End Sub

    By running this code, I could see Word is visible. From what you side, I also think you are using VBA code. Right? If yes, you also could refer to the KB article about automation word in VBA code: http://support.microsoft.com/kb/307216. Although it is for Word 2002, the code is also similiar to one in Word 2010/2007.

    If this post does not help you, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bessie Zhao Thursday, March 10, 2011 10:13 AM
    Friday, March 4, 2011 7:21 AM

All replies

  • Hello BinaryBob,

    Thanks for posting. Actually, I have used VBA code below to create a new Word application and make it visible.

    Sub test()
        Set wordApp = CreateObject("Word.Application")
        wordApp.Visible = True
    End Sub

    By running this code, I could see Word is visible. From what you side, I also think you are using VBA code. Right? If yes, you also could refer to the KB article about automation word in VBA code: http://support.microsoft.com/kb/307216. Although it is for Word 2002, the code is also similiar to one in Word 2010/2007.

    If this post does not help you, just feel free to follow up. Have a nice day.


    Bessie Zhao [MSFT]
    MSDN Community Support | Feedback to us
    Get or Request Code Sample from Microsoft
    Please remember to mark the replies as answers if they help and unmark them if they provide no help.

    • Marked as answer by Bessie Zhao Thursday, March 10, 2011 10:13 AM
    Friday, March 4, 2011 7:21 AM
  • Hi,

    I use vb script. Same problem.

    Also this code

        Set wordApp = CreateObject("Word.Application")
        wordApp.Visible = True

    does Word not make the active application.

    Who knows a solution?

    Regards

    Bert

    Saturday, March 12, 2011 4:39 PM