,可以通过以下步骤实现:
Dim script As String
script = "do shell script ""<AppleScript命令>"""
Shell script
set theFilePath to "<文件路径>"
set theContent to "<文件内容>"
set theFile to open for access theFilePath with write permission
set eof of theFile to 0
write theContent to theFile as «class utf8»
close access theFile
在上述代码中,将<文件路径>
替换为要生成的文件路径,将<文件内容>
替换为要写入文件的内容。
Sub GenerateUTF8File()
Dim script As String
script = "do shell script ""set theFilePath to """"<文件路径>"""" & return & " & _
"""set theContent to """"<文件内容>"""" & return & " & _
"""set theFile to open for access theFilePath with write permission" & return & " & _
"""set eof of theFile to 0" & return & " & _
"""write theContent to theFile as «class utf8»" & return & " & _
"""close access theFile"""
Shell script
End Sub
在上述代码中,将<文件路径>
替换为要生成的文件路径,将<文件内容>
替换为要写入文件的内容。
GenerateUTF8File
子过程即可生成UTF8文件。可以在VBA中调用该子过程,例如:Sub Test()
GenerateUTF8File
End Sub
以上就是在Mac Excel VBA中使用AppleScript生成UTF8文件的步骤。这种方法适用于需要在Mac Excel VBA中生成UTF8文件的场景。
没有搜到相关的沙龙
领取专属 10元无门槛券
手把手带您无忧上云