Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Posting on Qlik Community is temporarily paused. Thank you for patience and we'll update you soon!
cancel
Showing results for 
Search instead for 
Did you mean: 
Not applicable

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

Labels (1)
3 Replies
Not applicable
Author

Forgot to attach application, here it is.

Not applicable
Author

Did you get it working?

marcus_sommer
MVP
MVP

Just as idea - including a declaration from the qv-app within the sub-statement and call this as last action could help:

sub x

set doc = ActiveDocument

... excel-code

doc.Sheets("Main").Activate

end sub

Also should a closing from excel return the focus to the previous window.

sub x

...

oXL.close

oXL.quit

end sub

- Marcus