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

Announcements
Join us in Bucharest on Sept 18th for Qlik's AI Reality Tour! Register Now
cancel
Showing results for 
Search instead for 
Did you mean: 
Anonymous
Not applicable

Accessing the Windows API

Is it not possible to use this in a VBScript macro?

Declare Function GetDesktopWindow Lib "User32" () As Long
Declare Function GetWindowRect Lib "User32" (ByVal hWnd As Long, rectangle As RECT) As Long

What I want is a macro that will query Windows to determine the current screen resolution. This is simple in VB but I don't see how it can be done from within QlikView.

1 Solution

Accepted Solutions
Not applicable
Author

modified from something found on the internet. remember to allow system access.


Sub GetDisplayConfiguration
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DisplayConfiguration")

For Each objItem in colItems
msgbox("Name: " & objItem.DeviceName)
msgbox("Color depth: " & objItem.BitsPerPel)
msgbox("Horizontal resolution: " & objItem.PelsWidth)
msgbox("Vertical resolution: " & objItem.PelsHeight)
Next
End Sub


View solution in original post

3 Replies
Not applicable
Author

modified from something found on the internet. remember to allow system access.


Sub GetDisplayConfiguration
strComputer = "."
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * From Win32_DisplayConfiguration")

For Each objItem in colItems
msgbox("Name: " & objItem.DeviceName)
msgbox("Color depth: " & objItem.BitsPerPel)
msgbox("Horizontal resolution: " & objItem.PelsWidth)
msgbox("Vertical resolution: " & objItem.PelsHeight)
Next
End Sub


Not applicable
Author

Brian,

Here is a little macro I use that fetches screen height/width

sub ZoomToFitWindow

ActiveDocument.GetApplication.WaitForIdle
If ActiveDocument.GetApplication.ScreenWidth = 1280 and ActiveDocument.GetApplication.ScreenHeight = 1024 then
set thisSheet=ActiveDocument.ActiveSheet
set sp=thisSheet.GetProperties
sp.ZoomFactor = 1.0
thisSheet.SetProperties sp
else
ActiveDocument.ActiveSheet.FitZoomToWindow
end if

end sub

Regards,

Gordon

Anonymous
Not applicable
Author

Perfect, thanks!