Applescript Code to copy a table in Safari and paste to Excel worksheet

D

dog shaver

I am attempting to write Applescript code to copy a table in Safari and
paste special it, as text, to an
Excel worksheet.

When I perform the operation manually, all the rows of the Safari table
are
pasted into Excel
in a single column, i.e. after all of the data in a row of a table is
pasted
vertically into Excel,
the next row is pasted in the next open cell below in the same column,
as I need
it.

When I use the applescript line..."paste special on worksheet format
text" it
pastes the table
data in rows AND columns , like the table looks in Safari, but I do not
want it
pasted this
way.

Any ideas on how to get my Applescript code to perform the same manual
operation?

Thanks!
 
J

Jim Gordon MVP

Hi,

Excel can read HTML tables. A properly formatted HTML table should
simply paste as a table when you copy from Safari and paste into Excel.

Have you investigated web queries? That might be a solution for you to
check out.

Try this: put the URL all by itself into a text file, but use an
extension of .iqy instead of .txt (you can use Word to save as Text only).

The in Excel, from the DATA menu choose GET EXTERNAL DATA then RUN SAVED
QUERY.

Excel should then be able to display the table data from the web page.
The web site information is retained by Excel so you can refresh it
later if you want (unless you change the setting not to do this).

-Jim
 
D

dog shaver

Jim,

Thanks for the reply.

I may have worded my situation poorly thus making it confusing to
understand. I would like Excel, using an Applescript command, to paste
the HTML table without any formatting as, text.

When this operation is performed manually, the result is, data pasted
in a single column. This is what I want to replicate, using Applescript
but have not been successful.

Thanks Again!
dog shaver
 

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