I have been reading some posts here and also in another websites and even tried some one else code but nothing happened and don't know why.
1st I logon to my attachamte session named SERVICIO 3. Dont know if the name of the sess influences the code?
2nd I have a view of a menu in which i need to select option 2 and option 3 in asubmenu to get where i want.
So i want from a range of excel get that data an paste it on two fields(one is the service number and the another one is the visit number) and then: get the data of the "Fecha Atencion" Field. and the "Tecnico" Field and also if it's posible the "Coment.Ord.Serv." Lines.
This is a capture of the window
And here is the code I'd tried.
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Sub ExtractFreight
' Get the main system object
Dim Sessions As Object
Dim I as Integer
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
' Set the default wait timeout value
g_HostSettleTime = 100 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' Declare variables to contain the OLE objects
Dim objExcel As Object
Dim objWorkBook As Object
Dim gs as String
Dim r as Integer
Dim j as Integer
r=1
On Error Resume Next
' Attempt to get a reference to an open instance of Excel
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
'If GetObject failed, open a new instance of Excel
Set objExcel = CreateObject("Excel.Application")
If objExcel Is Nothing Then
MsgBox ("Could not open Excel.")
Exit Sub
End If
End If
' Make Excel visible on the screen
objExcel.Visible = True
' Create a new Workbook
Set objWorkBook = objExcel.Workbooks.Open("C:\macro\get freight fob\get freight fob.xls")
' BEFORE YOU RUN THIS YOU HAVE TO BE IN THE "MM" SCREEN WITH "VQ" IN THE FUNCTION FIELD
' Copy the result from Excel to host row 16 column 1-3
Do
result = objWorkBook.WorkSheets("Sheet1").Cells(r,1).Value 'Gets vendor number
Sess0.Screen.PutString result, 05, 25 'Enters vendor number
Sess0.Screen.Sendkeys("")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
gs = Sess0.Screen.GetString (14, 12, 15) 'Gets Freight desc
objWorkBook.WorkSheets("Sheet1").Cells(r,2).Value = gs 'Transfers freight desc to Excel
gs = Sess0.Screen.GetString (15, 47, 15) 'Gets FOB desc
objWorkBook.WorkSheets("Sheet1").Cells(r,3).Value = gs 'Transfers FOB desc to Excel
Sess0.Screen.Sendkeys("")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
r=r+1
Loop Until objWorkBook.WorkSheets("Sheet1").Cells(r,1).Value = ""
' Excel will remain open after this Sub ends.
' To close out Excel, unremark the following 4 lines of code. .
'objWorkBook.Close
'objExcel.Quit
'set objWorkBook = Nothing
'set objExcel = Nothing
End sub
Hope any one can help me thanks guys.
1st I logon to my attachamte session named SERVICIO 3. Dont know if the name of the sess influences the code?
2nd I have a view of a menu in which i need to select option 2 and option 3 in asubmenu to get where i want.
So i want from a range of excel get that data an paste it on two fields(one is the service number and the another one is the visit number) and then: get the data of the "Fecha Atencion" Field. and the "Tecnico" Field and also if it's posible the "Coment.Ord.Serv." Lines.
This is a capture of the window

And here is the code I'd tried.
' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$
Sub ExtractFreight
' Get the main system object
Dim Sessions As Object
Dim I as Integer
Dim System As Object
Set System = CreateObject("EXTRA.System") ' Gets the system object
If (System is Nothing) Then
Msgbox "Could not create the EXTRA System object. Stopping macro playback."
STOP
End If
Set Sessions = System.Sessions
If (Sessions is Nothing) Then
Msgbox "Could not create the Sessions collection object. Stopping macro playback."
STOP
End If
' Set the default wait timeout value
g_HostSettleTime = 100 ' milliseconds
OldSystemTimeout& = System.TimeoutValue
If (g_HostSettleTime > OldSystemTimeout) Then
System.TimeoutValue = g_HostSettleTime
End If
' Get the necessary Session Object
Dim Sess0 As Object
Set Sess0 = System.ActiveSession
If (Sess0 is Nothing) Then
Msgbox "Could not create the Session object. Stopping macro playback."
STOP
End If
If Not Sess0.Visible Then Sess0.Visible = TRUE
Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
' Declare variables to contain the OLE objects
Dim objExcel As Object
Dim objWorkBook As Object
Dim gs as String
Dim r as Integer
Dim j as Integer
r=1
On Error Resume Next
' Attempt to get a reference to an open instance of Excel
Set objExcel = GetObject(, "Excel.Application")
If objExcel Is Nothing Then
'If GetObject failed, open a new instance of Excel
Set objExcel = CreateObject("Excel.Application")
If objExcel Is Nothing Then
MsgBox ("Could not open Excel.")
Exit Sub
End If
End If
' Make Excel visible on the screen
objExcel.Visible = True
' Create a new Workbook
Set objWorkBook = objExcel.Workbooks.Open("C:\macro\get freight fob\get freight fob.xls")
' BEFORE YOU RUN THIS YOU HAVE TO BE IN THE "MM" SCREEN WITH "VQ" IN THE FUNCTION FIELD
' Copy the result from Excel to host row 16 column 1-3
Do
result = objWorkBook.WorkSheets("Sheet1").Cells(r,1).Value 'Gets vendor number
Sess0.Screen.PutString result, 05, 25 'Enters vendor number
Sess0.Screen.Sendkeys("")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
gs = Sess0.Screen.GetString (14, 12, 15) 'Gets Freight desc
objWorkBook.WorkSheets("Sheet1").Cells(r,2).Value = gs 'Transfers freight desc to Excel
gs = Sess0.Screen.GetString (15, 47, 15) 'Gets FOB desc
objWorkBook.WorkSheets("Sheet1").Cells(r,3).Value = gs 'Transfers FOB desc to Excel
Sess0.Screen.Sendkeys("")
Sess0.Screen.WaitHostQuiet (g_HostSettleTime)
r=r+1
Loop Until objWorkBook.WorkSheets("Sheet1").Cells(r,1).Value = ""
' Excel will remain open after this Sub ends.
' To close out Excel, unremark the following 4 lines of code. .
'objWorkBook.Close
'objExcel.Quit
'set objWorkBook = Nothing
'set objExcel = Nothing
End sub
Hope any one can help me thanks guys.