Excel 2002 - open .xls file and start macro or start file and go to specific cell

N

Newsgroups

Sorry about the previous post with Newsgroup - I forgot to check my
identity - I am reposting this again correctly. Please, I need help.

I am using a mainframe connectivity application (called Vista TN3270) to
pull data (realtime) from mainframe screens and paste that data into Excel
using copy function of TN3270 and the paste function from Excel.

I copy the info from mainframe into the clipboard and then I created an
AutoOpen macro in Excel that opens, pastes the data from the clipboard,
saves the data, then closes it and returns back to the TN3270 program for
the next round. However, after I have completed gathering data for one
client and I have pasted across from A1....AF1, I am ready to move to the
next row to start
pasting the next set of the same data into A2...AF2, but I cannot figure out
how to move the active cell to A2 within this circular data copy/paste
stream once it has completed its first set of data.

I open the Excel file by keying into the TN3270 mainframe program's
scripting/macro and type in ShellExecute("open",c:\file.xls,"","",1).
This shellexecute causes the excel file to open and the autoopen macro takes
over and grabs the data was copied into the clipboard and pastes it into the
next cell to the right of the last cell. But, now, I'm stuck when the next
set of similar data is copied over because I really want the next set of
data to start on the next line. I could let it go and copy the new data next
to the first set of data and so forth until it reachs the right side's
limit - and then the macro cannot complete it's call to paste to the next
cell because it cannot find one next to the last cell to the right and it
errors out.

Is there a way to cause a specific cell to return me to the next row?
Is there a way to start up the excel file (c:\file.xls) and tell it to go to
a specific cell (A2, for instance)?
Is there a way to start up the excel file (c:\file.xls) and add further
arguments that will start a macro within the .xls file that I am using?

Am I thinking about it all wrong?

I welcome anyone's help.
Thanks,
David
 
D

Dave Peterson

If there's always something in column A of the worksheet, you could use
something like this:

Option Explicit
sub Auto_Open()
Dim NextCell as range
with worksheets("sheet1")
set nextcell = .cells(.rows.count,"A").end(xlup).offset(0,1)
end with
application.goto nextcell, scroll:=true

'then the code to paste would go here.
end sub
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top