Re: Clipboard Woes
Re: Clipboard Woes
- Subject: Re: Clipboard Woes
- From: Kai Edwards <email@hidden>
- Date: Sat, 16 Feb 2002 22:49:26 +0000
on Wed, 6 Feb 2002 13:55:06 -0500 , "Sprague, Graham"
<email@hidden> wrote:
>
Can anyone help me with this problem?
>
>
I am using Mac OS 9.2.1, FMP 5.0v3 and Excel 98
>
>
I have a script that does the following to get data from FMP into Excel 98.
>
I keep getting this error in Excel "Unable to get Paste property of the
>
Worksheet class" but only intermittently. If I check the clipboard after
>
the FMP script uns it's got text in it. If I check the clipboard after Excel
>
launches it's empty. Anyone have any ideas why excel would clear the
>
clipboard? Please note that if I run the FMP script and then paste into
>
excel manually it works.
>
>
>
tell application "FileMaker Pro"
>
tell database "Job_Tracker
>
>
do script "Contract Report"
>
--Copy all records to clipboard
>
end tell
>
>
end tell
>
--clipboard has text in it
>
>
>
tell application "Microsoft Excel"
>
--clipboard is empty
>
Activate
>
>
set newWorkBook to (Create New document)
>
>
Select Sheet "Sheet1" of the newWorkBook
>
>
Select Range "R1C1"
>
Paste
>
>
end tell
I tried this with similarly curious results, Graham. At first, I thought it
might be something to do with the amount of data being copied - but that
proved not to be the case.
Like you, I believe that Excel may well be the culprit and - again like you
- I have not yet identified a single condition that seems to cause the
problem. Sometimes the script works and sometimes it doesn't. Most
frustrating.
Perhaps someone else on the list has previous experience/knowledge of this
quirky behaviour? [1]
In the meantime, you may like to consider this workaround:
To make it work, you'll need to change the "Contract Report" script in
FileMaker. I assume that the current FM script includes the command:
Copy All Records
- which is the part that needs to be changed.
Firstly, use the 'Export Records' command, naming the target file something
like "Job Tracker Data". Save as Tab-Separated Text, choosing the fields to
be exported as required. (For simplicity, I elected the desktop as the
folder to contain the new data file.)
Then, replace the 'Copy All Records' command with:
Export Records [Restore, No dialog, "Job Tracker Data"]
Finally, amend your AS script to something like this:
----------------------------------------------------------------------
tell application "FileMaker Pro"
tell database "Job_Tracker"
do script FileMaker script "Contract Report"
--export records to a desktop file called "Job Tracker Data"
end tell
end tell
tell application "Microsoft Excel"
Activate --optional
OpenText ((path to desktop folder as string) & "Job Tracker Data")
Save ActiveWorkbook In "Job Tracker Data" As xlNormal
--optional (but requires 'Activate' command above)
end tell
----------------------------------------------------------------------
The result should be exactly the same as if you had copied the data and
pasted it into a new Excel document. Well, FileMaker may throw up a brief
progress bar while it exports the data, and the Excel document will be named
"Job Tracker Data" instead of "WorkbookX".
Since you may want to save the file (or get your script to save it) as an
Excel document rather than a 'Text (Tab delimited)' file, I've also included
an optional 'Save ActiveWorkbook...' line. To avoid an Excel "File exists"
dialog at this point, you could change the name of the Excel version with
something like:
Save ActiveWorkbook In "Job Tracker Data (XL)" As xlNormal
( - and if required, tell the Finder to delete the original, tab-delimited
file.)
Oh - about the change in line 3. With the OS/FMP configuration I used for
testing, I needed to insert the term 'FileMaker script' - to stop FileMaker
choking whenever the "Job_Tracker" window was behind another FMP database.
Since you're using later versions, this detail may be redundant.
I'm sorry I can't help you pinpoint the problem with the original approach -
but I hope this suggestion helps you avoid any more clipboard woes for now!
Kai
---------------------------------------------------------------
[1] FWIW, Excel does seem to have a rather 'unusual' relationship with the
clipboard. As you know, copying a cell/range produces a marquee around the
selection (to confirm what has been copied to clipboard). Besides the
'command-period' keystroke, various standard Excel commands automatically
cancel the marquee. When this happens, the clipboard is also cleared - but
usually only if Excel was the source of the current clipboard contents.
Pure speculation of course - but I wonder if some occasional glitch in this
feature might be behind the mysterious disappearance of the FMP data?
--
**********************************
Kai Edwards Creative Resources
1 Compton Avenue Brighton UK
Telephone +44 (0)1273 326810
**********************************
_______________________________________________
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.