Excel 2013 macro working erratically in AppSphere (VDI) platform running Server 2008

Sparky1157

New member
Joined
Dec 22, 2017
Messages
1
Reaction score
0
Points
0
I was running an Excel 2010 macro on a Gen-Y VDI system running Windows 7 and everything worked just fine. Now, however, we upgraded to Excel 2013 with an AppSphere VDI system running Server 2008. The macro now behaves very erratic - sometimes it does nothing, and sometimes it will get part way through and then just quit.

Please see code below:

Code:
Declare Function SetForegroundWindow Lib "user32.dll" (ByVal hWnd As Integer) As Integer
Declare Function FindWindow Lib "user32.dll" Alias "FindWindowA" (ByVal lpClassName As String, ByVal lpWindowName As String) As Integer
Declare Function IsIconic Lib "user32.dll" (ByVal hWnd As Integer) As Boolean
Declare Function ShowWindow Lib "user32.dll" (ByVal hWnd As Integer, ByVal nCmdShow As Integer) As Integer
Declare Sub Sleep Lib "kernel32" (ByVal dwMilliseconds As Long)
Const SW_RESTORE As Integer = 9
Const SW_SHOW As Integer = 5
Sub Auto_Open()
    Dim WshShell As Object
    Dim hWnd As Integer
    Dim Temp As Integer 'Dummy variable - see below
    hWnd = FindWindow(vbNullString, "Inbox - ... - Outlook")
    If hWnd > 0 Then
        SetForegroundWindow (hWnd)
        If IsIconic(hWnd) Then  'Restore if minimized
            Temp = ShowWindow(hWnd, SW_RESTORE) 'Temp is meaningless, but compiler wanted "=" sign
        Else
            Temp = ShowWindow(hWnd, SW_SHOW)
        End If
        
'        SendKeys ("{Tab}")
'        Sleep 200   ' Pause for 1/5 of a second.
'        SendKeys ("{Tab}")
'        Sleep 200   ' Pause for 1/5 of a second.
'        SendKeys ("{Tab}")
'        Sleep 200   ' Pause for 1/5 of a second.
        SendKeys ("+{Tab}")  'Changed macro for Outlook 2013: Shift-Tab instead of 4 Tabs
        Sleep 200   ' Pause for 1/5 of a second.
        SendKeys ("{Down}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Down}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Down}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Down}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Down}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Enter}")
        Sleep 1000   ' Pause for 1 second.
        SendKeys ("{Enter}")
        Sleep 1000  ' Pause for 1 second.
        SendKeys ("{Tab}")
        Sleep 200   ' Pause for 1/5 of a second.
        SendKeys ("{Tab}")
        Sleep 200   ' Pause for 1/5 of a second.
        SendKeys ("{Tab}")
        Sleep 200   ' Pause for 1/5 of a second.
        SendKeys ("{Tab}")
        Sleep 200   ' Pause for 1/5 of a second.
        SendKeys ("^a")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("^c")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("^n")
        Sleep 1000  ' Pause for 1 second.
        SendKeys ("{Tab}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Tab}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Tab}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("{Tab}")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("^a")
        Sleep 100   ' Pause for 1/10 of a second.
        SendKeys ("^v")
    End If
    '
    ' Quit Excel
    '
    Application.Quit
End Sub
 
Last edited by a moderator:
Hi and welcome to the board

in the future please wrap code with code tags ( Go advanced- select code - click the# button)
I did it for you this time
Thanks
 
Are you familiar with loops ?

Code:
  for j=0 to 20
    sn=split("+T_D_D_D_D_D_E_E_T_T_T_T_^a_^c_^n_T_T_T_T_^a_^v","_")
    sp=split("211111992222119222211")
    sn(j)=replace(replace(replace(sn(j),"T","Tab","D","Down"),"E","Enter")

    SendKeys ("{""" & sn(j) """}")
    sleep sp(j)*100
  next
 
cross posted without links:
https://chandoo.org/forum/threads/e...phere-vdi-platform-running-server-2008.36779/
https://social.msdn.microsoft.com/F...vdi-platform-running-server-2008?forum=isvvba
http://www.tek-tips.com/viewthread.cfm?qid=1783191

sparky1157, for your information, you should always provide links to your cross posts.
This is a requirement, not just a request.
If you have cross posted at other places, please add links to them too.
Why? Have a read of http://www.excelguru.ca/content.php?184
 
Back
Top