MUKESHY12390
Well-known Member
- Joined
- Sep 18, 2012
- Messages
- 901
- Office Version
- 2013
- 2011
- 2010
- 2007
- Platform
- Windows
Hi All,
I have this code which works fine on "Local system Excel" but when I run same code with Citrix Excel ( open excel through Citrix App) it doesn't work, at end I get "Out of Memory"
anyone knows why this happen.????
I have this code which works fine on "Local system Excel" but when I run same code with Citrix Excel ( open excel through Citrix App) it doesn't work, at end I get "Out of Memory"
anyone knows why this happen.????
Code:
Option Explicit
Private Declare Function SwitchDesktop Lib "user32" (ByVal hDesktop As Long) As Long
Private Declare Function OpenDesktop Lib "user32" Alias "OpenDesktopA" (ByVal lpszDesktop As String, ByVal dwFlags As Long, ByVal fInherit As Long, ByVal dwDesiredAccess As Long) As Long
Private Declare Function CloseDesktop Lib "user32" (ByVal hDesktop As Long) As Long
Private Const DESKTOP_SWITCHDESKTOP As Long = &H100
Public p_lngHwnd As Variant
Public p_lngRtn As Variant
Public p_lngErr As Variant
Public system As Variant
Function Check_If_Locked() As String
' Dim p_lngHwnd As Long
' Dim p_lngRtn As Long
' Dim p_lngErr As Long
' Dim system As String
p_lngHwnd = OpenDesktop(lpszDesktop:="Default", dwFlags:=0, fInherit:=False, dwDesiredAccess:=DESKTOP_SWITCHDESKTOP)
If p_lngHwnd = 0 Then
system = "Error"
Else
p_lngRtn = SwitchDesktop(hDesktop:=p_lngHwnd)
p_lngErr = Err.LastDllError
If p_lngRtn = 0 Then
If p_lngErr = 0 Then
system = "Away"
Else
system = "Error"
End If
Else
system = "Unlocked"
End If
p_lngHwnd = CloseDesktop(p_lngHwnd)
End If
Check_If_Locked = system
End Function
Private Sub Form_Timer()
Dim i As Long
For i = 1 To 5
Sheet1.Cells(i, 1) = Check_If_Locked
Next i
End Sub
Last edited: