Re: how to empty clipboard contents?
Re: how to empty clipboard contents?
- Subject: Re: how to empty clipboard contents?
- From: Paul Berkowitz <email@hidden>
- Date: Mon, 22 Mar 2004 16:38:56 -0800
On 3/22/04 4:06 PM, "Michael Bovee" <email@hidden> wrote:
>
Thanks for the help so far! Your suggestions will really improve my
>
script. But before getting into that below, I still would like to know
>
if its possible to talk to the finder about the state of the clipboard?
>
Maybe not necessary for this script, but down the road.
Nothing to do with the Finder. There's a scripting addition
the clipboard
set the clipborad to
which works for the system clipboard and for application clipboards when
they're activated and in a tell block, but I think Excel uses its own
clicbpard so those may or may not work for transferring to another
application. Within Excel, you're better of with Copy and Paste if you're
positive you need them. Perhaps they would be useful for complex formats
(graphs, etc.) if copy/paste works in the UI. Value is just (I think - I'm
not really an Excel expert) for text, number or date content. But inthose
case there's absolutely no reason for Copy/Paste.
>
>
>
On Monday, March 22, 2004, at 06:21 PM, Paul Berkowitz wrote:
>
>
> On 3/22/04 2:47 PM, "Walter Ian Kaye" <email@hidden>
>
> wrote:
>
>> If you are copying within Excel, you should be able to bypass the
>
>> clipboard.
>
>> I don't know VBA, but in XLM you can do
>
>> =COPY(source_range,dest_range).
>
>>> tell application "Microsoft Excel"
>
>>> Activate
>
>>> Create New Workbook
>
>>> Save ActiveWorkbook In "Jaguar:Users:mbovee:Desktop:FILENAME.xls"
>
>
> That will save an empty new workbook, of course. Why not Save As after
>
> you've imported teh text file?
>
>
Because ultimately I want a script that will copy selections from
>
_many_ .txt files (which can be opened directly in Excel) into one
>
final Excel file. I havent sorted out yet which part(s) of the process
>
will be "looped" so in my first attempt, I visualized a solution that
>
began with saving what would become the master list Excel file first,
>
and then having some recursive loop that opens succesive text files
>
from someDirectory and copy/pasting the relevant part back into the
>
master file...
But you don't need copy/paste, with all the flip-flopping of activating all
teh different windows. That can easily be interrupted by something on your
screen, a random mouse click, leaning on the keyboard, while all thois
selction and copying is going on. AppleScript is a lot better than that sort
of tacky behavior. Import the text files to separate worrksheets or
workbooks, get the Value of complete ranges from each, and set the Value of
the next group of rows in your master sheet to the variable holding the
extracted Value. It's much better and safer. Why would you think that it
couldn't be done from multiple sheets and flles. Agreed, it's probably going
tpo be faster importing teh text files into Excel and getting the value
rather than parsing tab-text files unopened (although it really may not make
all thatmuch difference either).
>
>
>
>> you should be able to just 'Evaluate' the XLM (aka Excel 4.0 Macro)
>
>> command.
>
>
> You don't need VBA or Evaluate: it's all in the AppelScript Dictionary.
>
>
>
> set theRange to Value of Range "R12C1:R2513C2" of ActiveSheet -- a
>
> list
>
> of lists
>
> Activate Window "FILENAME.xls" -- if you really want to
>
> set Value of Range "R1C1:R2502C2" of ActiveSheet to theRange
>
> -- without activating: of Worksheet 1 of Workbook "FILENAME.xls"
>
>
>
>>> Select Range "R1C1"
>
>>> set ActiveCell to "time_sec"
>
>
>
> You need to set the Value, not the Cell itself. And don't need to keep
>
> selecting and setting ActiveCell:
>
>
Yeah, I understand that there's plenty of room for streamlining, here.
>
Thanks for your suggestions. This partial script is the result of
>
literally my first few hours of programming practice. (the hardest
>
part is getting over feeling like the 'manual labor' way I have been
>
doing this until now is actually a lot faster than making this script.
>
It may not be more efficient in the long run, but it IS faster! I hate
>
learning curve investments, but they pay off eventually...Got my Ph.D.
>
that way, after all! :0)
Right. It certainly takes a bit of time to learn the ropes and to stop
thinking of scripting imitating the User Interface methods you know when
behind-he-scenes scripting can be much bettre. But you need to get familiar
with the app's object model and AppleScript dictionary to do that - takes
time.
>
>
> set Value of Cell "R1C1" of ActiveSheet to "time_sec"
>
> set Value of Cell "R1C2" of ActiveSheet to "file_x"
>
>
>
> etc. (Those can even be assigned in one line as a Range:
>
>
>
> set Value of Range "R1C1:R1C2" to {" time_sec", "file_x"}
>
>
>
>
>
>>> Close Window "03195052.TXT"
>
>>> Activate Window "FILENAME.xls"
>
>
> -- is that necessary?
>
>
Probably not. I'm just trying to visually work through how I'll
>
eventually switch back and forth between each newly opened .txt file
>
and the Master file. Its difficult for me even to decipher some of the
>
examples in Matt Neuberg's book, which really jumps in assuming a _lot_
>
of prior programming experience, IMHO. But I'll get there.
>
>
Thanks again Paul and Walter, for sharing your insights!
Just set a variable to the master file (or keep referring to it by name if
you prefer). You can refer to all the other Workbooks by name or variable
too, and don't need to activate anything at all.
--
Paul Berkowitz
[demime 0.98b removed an attachment of type application/pkcs7-signature which had a name of smime.p7s]
_______________________________________________
applescript-users mailing list | email@hidden
Help/Unsubscribe/Archives:
http://www.lists.apple.com/mailman/listinfo/applescript-users
Do not post admin requests to the list. They will be ignored.