Skip to main content

I'm having an issue with some users running scripts I've written.  The scripts have worked for others and do work on my machine.  All of the users are running 9.1, as am I.  When I start the script on their machines, nothing happens, it just thinks it's running but doesn't actually do anything.  I have had this problem with multiple different users and multiple different scripts. All of the scripts are ones that launch Excel using the code [Set XLApp = CreateObject("Excel.Application")].

Here's the full code:


Sub Main
 Dim XLApp as Object
 Dim MYBook as Object
 Dim XLSheet as Object
 Dim XLRange as Object
 Dim varData
 Dim varData2
 Dim LenvarData2
 Dim NewvarData2
 Dim ScrnTxt as String

 'Checks for Screen C11, 7
 EMReadScreen ScrnTxt, 12, 3, 2
 If ScrnTxt = "Type choices" Then
  GoTo StartMacro
 Else
  GoTo ErrEnd3
 End If

 StartMacro:
 'Open XL Sheet
 Set XLApp = CreateObject("Excel.Application")
 XLApp.Visible = True
 XLApp.Workbooks.Open Filename:="P:\\Department Data\\CCM\\Macros\\Excel-ERP\\Set 1\\ERPData.xlsx"
 SysDelay 1
 Set MYBook = XLApp.Workbooks("ERPData.xlsx")
 Set XLSheet = MYBook.Worksheets("Data")
 Set XLSheet2 = MYBook.Worksheets("Uploaded")
 SysDelay 1
 EMSetCursor 19, 28

 'Start Loop
 For RW = 1 to 65000
  Set XLRange = XLSheet.Cells(1, 1)
  varData = STR(XLRange)
  If varData = "FIN" Then
   GoTo LFIN
  Else
   If varData = "" Then
    GoTo NoItem
   End If

   EMWaitCursor 5, 19, 28
   EMReadScreen ScrnTxt, 12, 3, 2
  
   'Screen Test 
   If ScrnTxt = "Type choices" Then
    GoTo Cont1
   Else
    GoTo ErrEnd
   End If
   
   Cont1:
   EMSendKey varData
   Set XLRange = XLSheet.Cells(1, 2)
   varData2 = STR(XLRange)
   LenvarData2 = InStr( 1, varData2, ".") 4   
   NewvarData2 = Left( varData2, LenvarData2)
   EMSendKey  "<Field_Plus>"
   EMWaitCursor 5, 21, 8
   EMReadScreen ScrnTxt, 11, 3, 2
   
   'Screen Test
   If ScrnTxt = "Cmp/Div/Loc" Then
    GoTo Cont2
   Else
    GoTo ErrEnd2
   End If
   
   Cont2:
   EMSendKey  "<Field_Plus>"
   EMSendKey  NewvarData2
   EMSendKey  "<Field_Plus>"
   EMSetCursor 21, 36
   EMSendKey  "<Enter>"
   EMWaitCursor 5, 21, 8

   'Makes sure data was entered as an allowance
   
   EMReadScreen ScrnTxt, 1,11,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,10,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,12,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,11,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,13,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,12,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,14,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,13,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,15,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,14,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,16,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,15,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,17,77
   If ScrnTxt = "t" Then
    EMReadScreen ScrnTxt, 3,16,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If
  
   AcceptItem:
   EMSendKey  "<PF10>"
   XLSheet2.Range("A1:B1").EntireRow.Insert
   XLSheet2.Range("A1").Value = varData
   XLSheet2.Range("B1").Value = NewvarData2
   XLSheet.Range("A1:B1").EntireRow.Delete
  End If
 Next RW

 ErrNoAllow:
 MsgBox "There was an error entering the allowance.  Please start script over from this item."
 Exit Sub

 ErrEnd:
 Msgbox "There was an error uploading this last item.  Script has been stopped."
 Exit Sub

 ErrEnd2:
 Msgbox "Invalid item number, or no BAC is selected.  Script has been stopped."
 Exit Sub

 ErrEnd3:
 Msgbox "Please use script in screen C11, 7."
 Exit Sub

 NoItem:
 MsgBox "No item detected.  Ending script."
 Exit Sub

LFIN:
Msgbox "The script has finished running.  No errors detected."
End Sub


Really I don't think the issue is with the script itself since some users can run it no problem.  Any help is much appreciated.  Thank you.


#Rumba

I'm having an issue with some users running scripts I've written.  The scripts have worked for others and do work on my machine.  All of the users are running 9.1, as am I.  When I start the script on their machines, nothing happens, it just thinks it's running but doesn't actually do anything.  I have had this problem with multiple different users and multiple different scripts. All of the scripts are ones that launch Excel using the code [Set XLApp = CreateObject("Excel.Application")].

Here's the full code:


Sub Main
 Dim XLApp as Object
 Dim MYBook as Object
 Dim XLSheet as Object
 Dim XLRange as Object
 Dim varData
 Dim varData2
 Dim LenvarData2
 Dim NewvarData2
 Dim ScrnTxt as String

 'Checks for Screen C11, 7
 EMReadScreen ScrnTxt, 12, 3, 2
 If ScrnTxt = "Type choices" Then
  GoTo StartMacro
 Else
  GoTo ErrEnd3
 End If

 StartMacro:
 'Open XL Sheet
 Set XLApp = CreateObject("Excel.Application")
 XLApp.Visible = True
 XLApp.Workbooks.Open Filename:="P:\\Department Data\\CCM\\Macros\\Excel-ERP\\Set 1\\ERPData.xlsx"
 SysDelay 1
 Set MYBook = XLApp.Workbooks("ERPData.xlsx")
 Set XLSheet = MYBook.Worksheets("Data")
 Set XLSheet2 = MYBook.Worksheets("Uploaded")
 SysDelay 1
 EMSetCursor 19, 28

 'Start Loop
 For RW = 1 to 65000
  Set XLRange = XLSheet.Cells(1, 1)
  varData = STR(XLRange)
  If varData = "FIN" Then
   GoTo LFIN
  Else
   If varData = "" Then
    GoTo NoItem
   End If

   EMWaitCursor 5, 19, 28
   EMReadScreen ScrnTxt, 12, 3, 2
  
   'Screen Test 
   If ScrnTxt = "Type choices" Then
    GoTo Cont1
   Else
    GoTo ErrEnd
   End If
   
   Cont1:
   EMSendKey varData
   Set XLRange = XLSheet.Cells(1, 2)
   varData2 = STR(XLRange)
   LenvarData2 = InStr( 1, varData2, ".") 4   
   NewvarData2 = Left( varData2, LenvarData2)
   EMSendKey  "<Field_Plus>"
   EMWaitCursor 5, 21, 8
   EMReadScreen ScrnTxt, 11, 3, 2
   
   'Screen Test
   If ScrnTxt = "Cmp/Div/Loc" Then
    GoTo Cont2
   Else
    GoTo ErrEnd2
   End If
   
   Cont2:
   EMSendKey  "<Field_Plus>"
   EMSendKey  NewvarData2
   EMSendKey  "<Field_Plus>"
   EMSetCursor 21, 36
   EMSendKey  "<Enter>"
   EMWaitCursor 5, 21, 8

   'Makes sure data was entered as an allowance
   
   EMReadScreen ScrnTxt, 1,11,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,10,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,12,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,11,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,13,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,12,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,14,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,13,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,15,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,14,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,16,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,15,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,17,77
   If ScrnTxt = "t" Then
    EMReadScreen ScrnTxt, 3,16,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If
  
   AcceptItem:
   EMSendKey  "<PF10>"
   XLSheet2.Range("A1:B1").EntireRow.Insert
   XLSheet2.Range("A1").Value = varData
   XLSheet2.Range("B1").Value = NewvarData2
   XLSheet.Range("A1:B1").EntireRow.Delete
  End If
 Next RW

 ErrNoAllow:
 MsgBox "There was an error entering the allowance.  Please start script over from this item."
 Exit Sub

 ErrEnd:
 Msgbox "There was an error uploading this last item.  Script has been stopped."
 Exit Sub

 ErrEnd2:
 Msgbox "Invalid item number, or no BAC is selected.  Script has been stopped."
 Exit Sub

 ErrEnd3:
 Msgbox "Please use script in screen C11, 7."
 Exit Sub

 NoItem:
 MsgBox "No item detected.  Ending script."
 Exit Sub

LFIN:
Msgbox "The script has finished running.  No errors detected."
End Sub


Really I don't think the issue is with the script itself since some users can run it no problem.  Any help is much appreciated.  Thank you.


#Rumba

Is your script running against an UNIX Host ?

Anyhow you  should consider to implement some object clean up.

In order to clean up successfully, you need to destroy all objects that refer to objects in the Excel App

- Close all workbooks

- Quit the app

XLSheet.Application.Quit ' Close the EXCEL sheet

Set XLSheet = Nothing ' Release all EXCEL Objects

Set XLBook = Nothing

Set XLApp = Nothing


I'm having an issue with some users running scripts I've written.  The scripts have worked for others and do work on my machine.  All of the users are running 9.1, as am I.  When I start the script on their machines, nothing happens, it just thinks it's running but doesn't actually do anything.  I have had this problem with multiple different users and multiple different scripts. All of the scripts are ones that launch Excel using the code [Set XLApp = CreateObject("Excel.Application")].

Here's the full code:


Sub Main
 Dim XLApp as Object
 Dim MYBook as Object
 Dim XLSheet as Object
 Dim XLRange as Object
 Dim varData
 Dim varData2
 Dim LenvarData2
 Dim NewvarData2
 Dim ScrnTxt as String

 'Checks for Screen C11, 7
 EMReadScreen ScrnTxt, 12, 3, 2
 If ScrnTxt = "Type choices" Then
  GoTo StartMacro
 Else
  GoTo ErrEnd3
 End If

 StartMacro:
 'Open XL Sheet
 Set XLApp = CreateObject("Excel.Application")
 XLApp.Visible = True
 XLApp.Workbooks.Open Filename:="P:\\Department Data\\CCM\\Macros\\Excel-ERP\\Set 1\\ERPData.xlsx"
 SysDelay 1
 Set MYBook = XLApp.Workbooks("ERPData.xlsx")
 Set XLSheet = MYBook.Worksheets("Data")
 Set XLSheet2 = MYBook.Worksheets("Uploaded")
 SysDelay 1
 EMSetCursor 19, 28

 'Start Loop
 For RW = 1 to 65000
  Set XLRange = XLSheet.Cells(1, 1)
  varData = STR(XLRange)
  If varData = "FIN" Then
   GoTo LFIN
  Else
   If varData = "" Then
    GoTo NoItem
   End If

   EMWaitCursor 5, 19, 28
   EMReadScreen ScrnTxt, 12, 3, 2
  
   'Screen Test 
   If ScrnTxt = "Type choices" Then
    GoTo Cont1
   Else
    GoTo ErrEnd
   End If
   
   Cont1:
   EMSendKey varData
   Set XLRange = XLSheet.Cells(1, 2)
   varData2 = STR(XLRange)
   LenvarData2 = InStr( 1, varData2, ".") 4   
   NewvarData2 = Left( varData2, LenvarData2)
   EMSendKey  "<Field_Plus>"
   EMWaitCursor 5, 21, 8
   EMReadScreen ScrnTxt, 11, 3, 2
   
   'Screen Test
   If ScrnTxt = "Cmp/Div/Loc" Then
    GoTo Cont2
   Else
    GoTo ErrEnd2
   End If
   
   Cont2:
   EMSendKey  "<Field_Plus>"
   EMSendKey  NewvarData2
   EMSendKey  "<Field_Plus>"
   EMSetCursor 21, 36
   EMSendKey  "<Enter>"
   EMWaitCursor 5, 21, 8

   'Makes sure data was entered as an allowance
   
   EMReadScreen ScrnTxt, 1,11,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,10,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,12,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,11,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,13,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,12,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,14,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,13,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,15,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,14,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,16,77
   If ScrnTxt = " " Then
    EMReadScreen ScrnTxt, 3,15,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If

   EMReadScreen ScrnTxt, 1,17,77
   If ScrnTxt = "t" Then
    EMReadScreen ScrnTxt, 3,16,23
    If ScrnTxt = "   " Then
     GoTo ErrNoAllow
    Else
     GoTo AcceptItem
    End If
   End If
  
   AcceptItem:
   EMSendKey  "<PF10>"
   XLSheet2.Range("A1:B1").EntireRow.Insert
   XLSheet2.Range("A1").Value = varData
   XLSheet2.Range("B1").Value = NewvarData2
   XLSheet.Range("A1:B1").EntireRow.Delete
  End If
 Next RW

 ErrNoAllow:
 MsgBox "There was an error entering the allowance.  Please start script over from this item."
 Exit Sub

 ErrEnd:
 Msgbox "There was an error uploading this last item.  Script has been stopped."
 Exit Sub

 ErrEnd2:
 Msgbox "Invalid item number, or no BAC is selected.  Script has been stopped."
 Exit Sub

 ErrEnd3:
 Msgbox "Please use script in screen C11, 7."
 Exit Sub

 NoItem:
 MsgBox "No item detected.  Ending script."
 Exit Sub

LFIN:
Msgbox "The script has finished running.  No errors detected."
End Sub


Really I don't think the issue is with the script itself since some users can run it no problem.  Any help is much appreciated.  Thank you.


#Rumba

Script is not running against a UNIX host.

I do have cleanup in most of my new scripts, this was an older one that I was sharing with another user.  It is not the cause of the issues as they hadn't run at all yet.