First off I'd like to thank everyone in this FORUM who have helped make our job much easier.
I'm new at this, but I need help figuring out how to run a macro only if the user is on the correct Extra screen. The way the macro is triggered is by using a tool bar button, which scrapes information from EXTRA and puts it in an Excel form.
I need the macro to look at a specific screen position (1, 2, 4) and if the value = XXXX then continue to run the macro otherwise stop and display an error message "you must be in XXXX screen to run macro"
I wasn't able to find a useful thread for this need yet.
Here's my code so far:
I'm new at this, but I need help figuring out how to run a macro only if the user is on the correct Extra screen. The way the macro is triggered is by using a tool bar button, which scrapes information from EXTRA and puts it in an Excel form.
I need the macro to look at a specific screen position (1, 2, 4) and if the value = XXXX then continue to run the macro otherwise stop and display an error message "you must be in XXXX screen to run macro"
I wasn't able to find a useful thread for this need yet.
Here's my code so far:
Code:
Sub Main
Dim Session As Object
Dim Sess0 As Object
Dim System As Object
Set System = CreateObject("Extra.system")
If (System Is Nothing) Then
MsgBox "Could not Create Session"
Stop
End If
Set Session = System.Sessions
Set Sess0 = System.Activesession
Dim ObjExcel As Object
Dim ObjWorkbook As Object
Dim ObjChart as Object
Set ObjExcel = CreateObject("Excel.Application.11")
objExcel.Visible=True
Set ObjWorkbook = objExcel.Workbooks.Open("C:RA sheet.xls")
result = Sess0.Screen.GetString(2, 73, 8)
ObjWorkbook.Worksheets("Sheet1").Cells(10, 3).Value = result 'SO Number
result = Sess0.Screen.GetString(15, 19, 24)
ObjWorkbook.Worksheets("Sheet1").Cells(10, 5).Value = result 'Part Number
result = Sess0.Screen.GetString(15, 65, 13)
ObjWorkbook.Worksheets("Sheet1").Cells(10, 8).Value = result 'Serial/RT
result = Sess0.Screen.GetString(14, 5, 2)
ObjWorkbook.Worksheets("Sheet1").Cells(10, 9).Value = result 'Quantity
End Sub