• Hi All

    Please note that at the Chandoo.org Forums there is Zero Tolerance to Spam

    Post Spam and you Will Be Deleted as a User

    Hui...

  • When starting a new post, to receive a quicker and more targeted answer, Please include a sample file in the initial post.

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

Steve Schroeder

New Member
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:
Steve,

Firstly, Welcome to the Chandoo.org Forums

A few things to consider

SendKeys is rarely, if ever, recommended for what you are trying to achieve

Does AppSphere VDI have any API's or ODBC/SQL method of access ?

I would put an Application.Enableevents=False line, before the send keys, to stop miscellaneous or unexpected events happening

Are you sure the Sendkeys sequence is the same for the new version of the software ?
 
You have cross posted this question, not just once but many times.

https://social.msdn.microsoft.com/F...vdi-platform-running-server-2008?forum=isvvba
http://www.tek-tips.com/viewthread.cfm?qid=1783191
https://www.excelguru.ca/forums/showthread.php?8685-Excel-2013-macro-working-erratically-in-AppSphere-(VDI)-platform-running-Server-2008

If you had taken some of the time you used to cross post to read the rules you would understand why this behavior is frowned on, not wholesale ban but asking YOU to show some manners and courtesy to members by explaining to members what you are doing so as not to waste their time
 
My apologies, bobhc ... my intention was not to offend anyone, but simply to obtain an answer to my question. I had first approached Tek-Tips regarding this but did not get a satisfactory answer & no one else was replying. So my efforts were spent trying to expand my horizons in hopes of getting a direct answer to my question.

I apologize for being ignorant of the "rules," as you say. However, I've now taken the time to visit the following websites and cannot find any reference to what you're saying....

https://chandoo.org/wp/policies/
https://chandoo.org/wp/policies/privacy-policy/
https://chandoo.org/wp/policies/terms-and-conditions/
https://chandoo.org/wp/policies/disclaimer/

Perhaps I'm missing something here. Please cite your source.

And thank you so much for such a warm welcome! My apologies for wasting your time.
 
Back
Top