Re: Save of CSV Formatted File Fails on Excel 15.36 under Sierra
Re: Save of CSV Formatted File Fails on Excel 15.36 under Sierra
- Subject: Re: Save of CSV Formatted File Fails on Excel 15.36 under Sierra
- From: Yvan KOENIG <email@hidden>
- Date: Tue, 25 Jul 2017 11:43:19 +0200
Off list, I sent the code below to Thomas Maffucci.
property folderName : "Goog Ports"
# Create - if needed - the folder supposed to receive the created files.
set p2d to path to desktop
set theFolder to (p2d as text) & folderName
tell application "System Events"
if not (exists folder theFolder) then make new folder at end of p2d
with properties {name:folderName}
end tell
set Testlst to {"Test 11", "Test 12", "Test 13", "Test 21", "Test 22", "Test
23"}
repeat with curTest in Testlst
set Prenam to curTest
my BuildPortal(Prenam)
end repeat
on BuildPortal(Testno)
log "point 1"
set thePath to (path to desktop as text) & folderName & ":UPL" & Testno
& ".csv"
--log "point 2"
# Required to get rid a sandboxing behavior.
close access (open for access file thePath)
log "point 3"
tell application "Microsoft Excel"
activate
--log "point 4"
set newBook to make new workbook
log "point 5"
--global Shtno
set NewbkNme to name of active workbook
--log "point 6"
set value of cell ("A1") to Testno
set value of cell ("B1") to "Data Follows"
set value of cell ("A2") to "100"
set value of cell ("B2") to "200"
log "point 7"
repeat 50 times
try
log "try to save"
save workbook as newBook filename thePath file
format CSV file format with overwrite
exit repeat
end try
end repeat
log "point 8"
close newBook saving no
log "point 9"
end tell
-- delay 0.5 # May be useful
end BuildPortal
The loop (originally repeat 2 times, now repeat 50 times) is here to try to
solve an odd behavior striking on T.M. machine.
Some times the script does it's duty (as it does on some other users machine)
but sometimes the save process fails:
save workbook as workbook "Workbook9" filename "Macintosh
HD:Users:??????:Desktop:Goog Ports:UPLTest 11.csv" file format CSV file format
with overwrite
--> error number -50
(*try to save*)
save workbook as workbook "Workbook9" filename "Macintosh
HD:Users:??????:Desktop:Goog Ports:UPLTest 11.csv" file format CSV file format
with overwrite
--> error number -50 (*point 8*)
close active workbook saving no
(*point 9*)
I'm wondering if this behavior may be due to bad blocks available on T.M.
machine.
The idea is :
close access (open for access file thePath) creates an entry in the volume
Table of Contents which means that it tell it that a given block is attributed
to the described path, but as nothing is written in the block, it's not warned
if the block is bad.
Some attempts seem to try to write on wrong blocks and so fail.
When the system try to write on good blocks, the process is correctly done.
Maybe some reader will be fair enough to test the script on their machine to
triple check that the oddity is not the code by itself.
More, I wish to have backup about my assumption about possible bad blocks.
The asker's machine is a new ones but we never know.
Yvan KOENIG running Sierra 10.12.6 in French (VALLAURIS, France) mardi 25
juillet 2017 11:42:38
_______________________________________________
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