O$: opening txt file in Excel via Applescript

Reg Paling Reg.Paling at Lokanet.com
Thu Dec 8 17:55:59 EST 2011


Hi Andrew,

Here's a snippet from my code:

Do $runapplescript(lvScript) Returns lvResult
If lvResult=0     ;; 0 is good...
Else If lvResult=-1753     ;; Don't know what this error code means but 
it appears to be OK (This error comes from the Word object)
Else
    Quit method 0 ;; return an error to my calling method in Omnis (my 
convention is 1 is good)
End If

  - - This is part of a method that establishes a connection to Word or 
Excel, before even trying to open a file.
  - - The upshot of this is I just ignore the -1753 error and treat it 
as success (equivalent to 0).
  - - I recall I invested/wasted some considerable time on this.  In the 
end the code above ran OK for years in at least 1 site.

Cheers,
Reg




On 9/12/11 8:55 AM, Andrew Pavey wrote:
> I have the following code (which runs perfectly in Apple's Script 
> Editor) to open a tab delimited text file just created in Studio 
> (v5.1). The really nice bit of this code is the autofit line which 
> resizes the columns to the max size of the data in the column.
>
> Begin text block
> Text: tell application "Microsoft Excel" (Carriage return)
> Text: activate (Carriage return)
> Text: open "[pFilePath]" (Carriage return)
> Text: " (Carriage return)
> Text: autofit (columns of used range of active sheet) (Carriage 
> return)     ;; thank you Paul Berkowitz
> Text: " (Carriage return)
> Text: end tell (Carriage return)
> End text block
>
> when I run this using
> Do $runapplescript(lvScript,lvResult) Returns lvErrCode
>
> I occasionally get a -1753 error. It was happening yesterday 
> afternoon, and this morning it isn't (grrr!!)
> Can anyone tell me where the -1753 error comes from, and/or where I'd 
> get a lookup list of that error code set?
>
> Additionally, if the txt file is already open in Excel I get an error 
> in setting the export path, there appears to be no way in Studio to 
> trap this error. My work around has been to always create a unique 
> file name before attempting to open the txt  file in Excel, but it 
> would be nice to have a way of determining if the file was already open.
> At this stage I'm only working on Macs.
>
> TIA
>
> Andrew Pavey




More information about the omnisdev-en mailing list