Re: AppleScript-Users Digest, Vol 17, Issue 56
Re: AppleScript-Users Digest, Vol 17, Issue 56
- Subject: Re: AppleScript-Users Digest, Vol 17, Issue 56
- From: David Crowe via AppleScript-Users <email@hidden>
- Date: Wed, 6 May 2020 18:35:32 -0600
Yvan;
The file very definitely exists. “open workbook” wouldn’t work otherwise.
Are you saying I should create the file again?
- David
>
> Message: 1
> Date: Wed, 6 May 2020 13:52:42 -0600
> From: David Crowe <email@hidden
> <mailto:email@hidden>>
> To: email@hidden
> <mailto:email@hidden>
> Subject: Fun with Excel
> Message-ID: <email@hidden
> <email@hidden">mailto:email@hidden>>
> Content-Type: text/plain; charset="utf-8"
>
> This code used to work:
>
>
> tell application "Microsoft Excel"
> open workbook workbook file name
> "/Users/david/Documents/TheInfectiousMyth/Marketing/Email and Donors.xlsx"
> tell workbook "Update Email List.xlsx"
> tell worksheet "TIM Emails"
> -- Bail if already here
> set searchRange to range ("C2:C9999")
> try
> set foundRange to find searchRange what
> theEmailAddress
> -- If the email address is not present an error
> will mean that the following code is not executed
> tell me
> activate
> display dialog "Email address <" &
> theEmailAddress & "> already in file" giving up after 3
> return
> end tell
> end try
> -- Find first blank row
> set blank to ""
> set searchRange to range ("C2:C9999")
> set foundRange to find searchRange what blank
> set theRow to first row index of foundRange as text
> set value of cell ("A" & theRow) to FirstName
> set value of cell ("B" & theRow) to LastName
> set value of cell ("C" & theRow) to theEmailAddress
> set value of cell ("D" & theRow) to DateString
> set value of cell ("E" & theRow) to "Email"
> end tell
> try
> save
> on error errmsg number errnum
> tell me
> activate
> display dialog "Cannot save file. " & errmsg &
> " (" & errnum & ")"
> end tell
> end try
> end tell
> end tell
>
>
> But now it is generating an error on the ?save? line. I tried:
> save it in <posix file string>
> save it in <apple file string>
> save in file <apple file string>
> save workbook ?Update Email List.xlsx? in <apple file string>
>
> And all generate an Excel error that the object I?m trying to access does not
> exist:
> Cannot save file. The object you are trying to access does not exist (-1728)
>
> Quite likely Microsoft has auto-updated Excel. I wonder if anyone else has
> found a similar issue recently.
>
> Regards,
> David Crowe
> -------------- next part --------------
> An HTML attachment was scrubbed...
> URL:
> <https://lists.apple.com/mailman/private/applescript-users/attachments/20200506/cc61b9bb/attachment.htm
>
> <https://lists.apple.com/mailman/private/applescript-users/attachments/20200506/cc61b9bb/attachment.htm>>
>
> ------------------------------
>
> Message: 2
> Date: Wed, 6 May 2020 22:09:22 +0200
> From: Yvan KOENIG <email@hidden <mailto:email@hidden>>
> To: liste AppleScript US <email@hidden
> <mailto:email@hidden>>
> Subject: Re: Fun with Excel
> Message-ID: <email@hidden
> <email@hidden">mailto:email@hidden>>
> Content-Type: text/plain; charset="utf-8"
>
>
>
>> Le 6 mai 2020 ? 21:52, David Crowe via AppleScript-Users
>> <email@hidden
>> <mailto:email@hidden>> a ?crit :
>>
>> This code used to work:
>>
>>
>> tell application "Microsoft Excel"
>> open workbook workbook file name
>> "/Users/david/Documents/TheInfectiousMyth/Marketing/Email and Donors.xlsx"
>> tell workbook "Update Email List.xlsx"
>> tell worksheet "TIM Emails"
>> -- Bail if already here
>> set searchRange to range ("C2:C9999")
>> try
>> set foundRange to find searchRange what
>> theEmailAddress
>> -- If the email address is not present an error
>> will mean that the following code is not executed
>> tell me
>> activate
>> display dialog "Email address <" &
>> theEmailAddress & "> already in file" giving up after 3
>> return
>> end tell
>> end try
>> -- Find first blank row
>> set blank to ""
>> set searchRange to range ("C2:C9999")
>> set foundRange to find searchRange what blank
>> set theRow to first row index of foundRange as text
>> set value of cell ("A" & theRow) to FirstName
>> set value of cell ("B" & theRow) to LastName
>> set value of cell ("C" & theRow) to theEmailAddress
>> set value of cell ("D" & theRow) to DateString
>> set value of cell ("E" & theRow) to "Email"
>> end tell
>> try
>> save
>> on error errmsg number errnum
>> tell me
>> activate
>> display dialog "Cannot save file. " & errmsg &
>> " (" & errnum & ")"
>> end tell
>> end try
>> end tell
>> end tell
>>
>>
>> But now it is generating an error on the ?save? line. I tried:
>> save it in <posix file string>
>> save it in <apple file string>
>> save in file <apple file string>
>> save workbook ?Update Email List.xlsx? in <apple file string>
>>
>> And all generate an Excel error that the object I?m trying to access does
>> not exist:
>> Cannot save file. The object you are trying to access does not exist (-1728)
>>
>> Quite likely Microsoft has auto-updated Excel. I wonder if anyone else has
>> found a similar issue recently.
>>
>> Regards,
>> David Crowe
>>
>
>
> If my memory is right, it may be useful to create the file before saving in
> it.
>
> tell application "System Events" to make new file at end of folder
> "/Users/david/Documents/TheInfectiousMyth/Marketing/" with properties
> {name:Update Email List.xlsx"}
>
> Yvan KOENIG running High Sierra 10.13.6 in French (VALLAURIS, France)
> mercredi 6 mai 2020 22:05:52
_______________________________________________
Do not post admin requests to the list. They will be ignored.
AppleScript-Users mailing list (email@hidden)
Help/Unsubscribe/Update your Subscription:
Archives: http://lists.apple.com/archives/applescript-users
This email sent to email@hidden