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 IamaSherpa on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Writing to Excel Spreadsheet from Extra Attachmate

Status
Not open for further replies.

ulchm

Programmer
May 22, 2007
23
CA
Hey guys, love this forum and have been using it ever since I got this job as an application developer here.

Luckily enough, I haven't had to create an account before today as I could always find what I wanted on here.

Today is the exception.

I'm coding a macro for extra (quite a switch from my usual .net development) and I'm having some trouble writing data from attachmate back to excel.

For i = 3 To xl_wb.Sheets(2).UsedRange.Rows.Count

'get the cell value at the desired location
curr_cell = xl_wb.Sheets(2).Cells(i, 2)

'enter the information to go to the SDDQ screen
MyScreen.MoveTo 1,8
MyScreen.SendKeys("SDDQ")
MyScreen.MoveTo 2,8
MyScreen.SendKeys(curr_cell)
MyScreen.SendKeys ("<Enter>")
waiting = MyScreen.WaitForString("PROJECTED", 9,5)

'go to page 1 of the SDDQ screen
MyScreen.MoveTo 1,8
MyScreen.SendKeys("p1")
MyScreen.SendKeys("<Enter>")
waiting = MyScreen.WaitForString("ITEM CLASS", 7,2)

'put the price in the appropriate cell of the spreadsheet
price = MyScreen.GETstring(7,66, 13) 'row 7 column 65 for 14 characters

'*******************************'
'This is where I want to write PRICE to cell i,7



Next i



I commented above where I want to put the 'price' variable, if someone could help me out that would be great.

Oh also, by all means if I'm not doing something the best way there is to do it, let me know! I'm definitely a noobie when it comes to this language.
 

Dim xl_app As Object, xl_wb As Object, curr_cell As String, xl_file As String
Dim word_app As Object, word_doc As Object, word_file As String
Dim i As Integer, j As Integer, iRows As Long, iCols As Long, curr_line As String


xl_file = "C:\Temp\May23.xls"

Set xl_app = CreateObject("Excel.Application")
Set xl_wb = xl_app.Workbooks.Open(xl_file)


should probably have include this part above my loop, sorry about that.
 
xl_wb.Sheets(2).Cells(i, 7) = price

who knew it would be that easy...
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top