Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Excel to Extra

Status
Not open for further replies.

FrankMhere

Technical User
Jul 2, 2007
4
US
I enter information from Excel into Extra. I was wondering if this could be done via Macro. I set up a Macro and then cut and paste the information into Word. From Word I used the mail merge function to modify the code and get the information from Excel. However, I'm thinking that it would be easier and better if I could point the Macro to Excel and just go straight from Excel to Extra. I hope that makes sense. Here is a portion of the code that I used for the Macro.

Code:
'--------------------------------------------------------------------------------
' This macro was created by the Macro Recorder.
' Session Document: "AA0000 SESSION1.EDP"
' Date: Wednesday, May 30, 2007 14:34:44
' User: AAAAAAA
'--------------------------------------------------------------------------------

' Global variable declarations
Global g_HostSettleTime%
Global g_szPassword$

Sub Main()
'--------------------------------------------------------------------------------
' Get the main system object
	Dim Sessions As Object
	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 = 50		' 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)
	
' This section of code contains the recorded events
Sess0.Screen.Sendkeys("<Clear>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("text1<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("text2<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("ExcelcolumnA<Tab>ExcelcolumnB<Tab>ExcelcolumnC<Tab><Tab><Tab><Tab><Tab>ExcelcolumnD<Tab>ExcelcolumnE<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>ExcelcolumnF<Tab>ExcelcolumnG<Tab><BackTab>ExcelcolumnH<Tab>ExcelcolumnI<Tab>text3<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><EraseEOF>text4<Tab><Tab>text5<Tab><Tab><Tab><Tab><Tab><Tab>text6<Tab><Tab><Tab><Tab><Tab><Tab>ExcelcolumnJ<Tab><Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>text7<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>text8<Tab><Tab><Tab><Tab>text9<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>text10<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Pf2>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Pf2>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Clear>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("text11<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("text12<Tab><Tab><Tab><Tab><Tab>text13<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("=text14<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Tab><Tab><EraseEOF>text15<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>text16<Tab><Tab><EraseEOF>text17<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Clear>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("text18<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("text19<Tab><Tab>text20<Tab>text21<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab><Tab>text22<Tab><BackTab><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right><Right>text23<Left>text24<Tab>text25<Tab>text26<BackSpace><BackSpace>text27<BackSpace>text28<Enter>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime)
	Sess0.Screen.Sendkeys("<Clear>")	
	Sess0.Screen.WaitHostQuiet(g_HostSettleTime) 
	System.TimeoutValue = OldSystemTimeout
End Sub
 
Sub Main

'Extra Objects
Dim System As Object
Dim ExScreen As Object
Set System = CreateObject("EXTRA.System")
Set ExScreen = System.ActiveSession.Screen

'Excel Objects
Dim appExcel As Object
Dim wbExcel As Object
Dim aSheet As Object

Set AppExcel = CreateObject("Excel.Application")
Set wbExcel = AppExcel.WorkBooks.Open("Drive/YourFile.xls")
Set aSheet = wbExcel.Sheets("SheetName")

For x = 1 to aSheet.UsedRange.Rows.Count

ExScreen.SendKeys ("<clearpagecursorhome>"
ExScreen.PutString aSheet.Cells(x,1).text ,1 ,1
ExScreen.PutString "Press any key to get next Excel Row:",2,1
ExScreen.WaitForKeys

Next

appExcel.Quit
End Sub


[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Should get you started.

[thumbsup2] Wow, I'm having amnesia and deja vu at the same time.
I think I've forgotten this before.


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top