S
SteveM
I created an application in Excel 2003 and adapted it to also work with
computers using Excel 2007 (all Windows XP). In use, a button calls the
RunBoth subroutine. Excel first tests that one or two windows are open in a
non-Office application, and if so, gets more user input and then sends
commands to interact with those windows to generate, paste into Excel,
process and compile information about each of a series of employees. Other
supervisors copy and paste the application to their computer or their network
site to use for the same purpose, possibly with a different name.
The programming works fine on my Excel 2003 computer and another's Excel
2007 computer, but on other Excel 2003 computers with supposedly the same
configuration it gives an error message "Invalid prodedure call or argument"
when it reaches the last command shown below (AppActivate ThisApp). This is
where the window of this Excel application is supposed to be re-activated in
order to send additional commands. Why would it choke here on those other
Excel 2003 computers?
Dim cnt
Dim IsIt As Boolean
Private Const AuxInt = "Agent AUX Interval" 'name of Avaya report
Private Const SumInt = "Agent Summary Interval" 'name of Avaya report
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Public Function ThisApp() As String
If Ver < 12 Then ThisApp = ActiveWorkbook.Name
If Ver = 12 Then ThisApp = ActiveWorkbook.Name & " [Compatibility Mode]"
End Function
Public Function Ver() As Integer
Ver = Val(Application.Version)
End Function
Sub IsItOpen(OtherApp As String)
IsIt = True
On Error GoTo NotOpen
AppActivate OtherApp
SendKeys "%(rr)", True
DoEvents
Do While FindWindow(vbNullString, OtherApp) = 0
DoEvents
Loop
SendKeys "%(rr)", True
DoEvents
Exit Sub
NotOpen:
What = OtherApp & " is probably not open." & vbNewLine & "If it is open,
click on it and click Run again." & vbNewLine & "If it isn't, open it and
click Run again."
MsgBox What, vbOKOnly
IsIt = False
End Sub
Sub RunBoth()
IsItOpen AuxInt
If Not IsIt Then: Exit Sub
AppActivate ThisApp
...........etc
computers using Excel 2007 (all Windows XP). In use, a button calls the
RunBoth subroutine. Excel first tests that one or two windows are open in a
non-Office application, and if so, gets more user input and then sends
commands to interact with those windows to generate, paste into Excel,
process and compile information about each of a series of employees. Other
supervisors copy and paste the application to their computer or their network
site to use for the same purpose, possibly with a different name.
The programming works fine on my Excel 2003 computer and another's Excel
2007 computer, but on other Excel 2003 computers with supposedly the same
configuration it gives an error message "Invalid prodedure call or argument"
when it reaches the last command shown below (AppActivate ThisApp). This is
where the window of this Excel application is supposed to be re-activated in
order to send additional commands. Why would it choke here on those other
Excel 2003 computers?
Dim cnt
Dim IsIt As Boolean
Private Const AuxInt = "Agent AUX Interval" 'name of Avaya report
Private Const SumInt = "Agent Summary Interval" 'name of Avaya report
Private Declare Function FindWindow Lib "user32" Alias "FindWindowA" (ByVal
lpClassName As String, ByVal lpWindowName As String) As Long
Public Function ThisApp() As String
If Ver < 12 Then ThisApp = ActiveWorkbook.Name
If Ver = 12 Then ThisApp = ActiveWorkbook.Name & " [Compatibility Mode]"
End Function
Public Function Ver() As Integer
Ver = Val(Application.Version)
End Function
Sub IsItOpen(OtherApp As String)
IsIt = True
On Error GoTo NotOpen
AppActivate OtherApp
SendKeys "%(rr)", True
DoEvents
Do While FindWindow(vbNullString, OtherApp) = 0
DoEvents
Loop
SendKeys "%(rr)", True
DoEvents
Exit Sub
NotOpen:
What = OtherApp & " is probably not open." & vbNewLine & "If it is open,
click on it and click Run again." & vbNewLine & "If it isn't, open it and
click Run again."
MsgBox What, vbOKOnly
IsIt = False
End Sub
Sub RunBoth()
IsItOpen AuxInt
If Not IsIt Then: Exit Sub
AppActivate ThisApp
...........etc