3 Replies Latest reply: Sep 10, 2013 3:25 AM by Marcus Sommer RSS

    Get focus back on the application

      Hello,

       

      I am using macro code to show an "Open file"-dialog via Excel wich i found here: http://qlikviewmaven.blogspot.se/2009/03/browse-for-file-macro-button.html

       

       
      Sub Browse_for_File
         Set oXL=CreateObject("Excel.Application")
         f_name=oXL.GetOpenFilename("All Files (*.*),*.*",,"Select file",False)
         If f_name="False" then 
            Set oXL=nothing
            Exit sub
         End If
         ret=ActiveDocument.GetVariable("file_pathname").SetContent(f_name,false)
         Set oXL=nothing
         Set objShell = CreateObject("WScript.Shell")
         objShell.AppActivate "QlikView - [Test]"
         Set objShell=Nothing
      End Sub 
      

       

       

      The problem is that when i use the sub, qlikview looses focus and another window gets focus.

      Is there a way to solve this?  Tried  objShell.AppActivate

      Won't even work when i loop through names and get the window title from the application..

       

      Attached is a test application.

       

      Cheers,

      Martin