Mac 용 Excel에서 VBA 스크립트를 사용하여 XML 파일을 생성하는 다음 코드는 Mac 2016입니다. Mac에서 UTF-8 파일을 생성 할 수 없다는 것이 유감이지만 Excel VBA. ExcelScript 내에서 AppleScript를 호출하는 것이 좋습니다. AppleScript를 사용한 적이 없습니다. Excel에서 코드를 변환하여 AppleScript에 호출하여 UTF-8 파일을 생성 한 다음이 파일에 쓰기 만하면 큰 도움이 될 것입니다. .Mac Excel VBA에서 AppleScript를 사용하여 UTF-8 파일 생성
Sub createXMLFile()
Dim My_Path1 As String
My_Path1 = MacScript("return (path to desktop folder) as string")
Dim rng1 As Range, rng2 As Range, cl As Range
Set rng1 = ThisWorkbook.Sheets("upload").Range("A2")
Set rng1 = ThisWorkbook.Sheets("upload").Range(rng1, rng1.End(xlDown))
Dim strPath As String
strPath = "cancel_reasons"
Dim fnum As Integer
fnum = FreeFile()
Open My_Path1 & Trim(strPath) & ".xml" For Output As #fnum
Print #fnum, "<?xml version=""1.0""?>"
Print #fnum, "<x:cancelShiftReasons xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation=""urn:cancelShiftReasons ./cancelshiftreasonmaster.xsd"" xmlns:x=""urn:cancelShiftReasons"">"
For Each cl In rng1
Call write_xml_line_2(cl, fnum)
Next cl
Print #fnum, "</x:cancelShiftReasons>"
Close #fnum
End Sub