chaoj
07-22-2016, 08:14 PM
Hello everyone ,
I encounter a problem that using the AppleScriptTask to run Apple Script but can not close access of a file,
My VBA code is below
Sub createFile()
Dim RunMyScript
RunMyScript = AppleScriptTask("wfile.scpt", "hl", "parm")
End Sub
and my Apple Script is below
on hl(parm1)
set theFile to (path to desktop as text) & "congtou4.csv"
set referenceNumber to open for access theFile with write permission
write "aa,bb,cc,dd,ee" to referenceNumber
display dialog "rnum is :" & referenceNumber
try
close access referenceNumber
on error errText number errNum
display dialog errText & errNum
end try
display dialog "close ok"
end hl
I tested many times , the file was created and there was data in the file
but the close access statement , I got an error : Parameter error -50
I can only invoke AppleScriptTask once to write, the second time I got the error that the file is open, can anyone help to close the access ? Thanks !
I encounter a problem that using the AppleScriptTask to run Apple Script but can not close access of a file,
My VBA code is below
Sub createFile()
Dim RunMyScript
RunMyScript = AppleScriptTask("wfile.scpt", "hl", "parm")
End Sub
and my Apple Script is below
on hl(parm1)
set theFile to (path to desktop as text) & "congtou4.csv"
set referenceNumber to open for access theFile with write permission
write "aa,bb,cc,dd,ee" to referenceNumber
display dialog "rnum is :" & referenceNumber
try
close access referenceNumber
on error errText number errNum
display dialog errText & errNum
end try
display dialog "close ok"
end hl
I tested many times , the file was created and there was data in the file
but the close access statement , I got an error : Parameter error -50
I can only invoke AppleScriptTask once to write, the second time I got the error that the file is open, can anyone help to close the access ? Thanks !