MacOS에서 VBA 쓸 때 파일이나 폴더 이름이 한글이어서 오류가 생기나요?

Michael Lee 0 평판 포인트
2025-11-05T22:49:46.47+00:00

MacOS에서 Word를 사용하는 데 VBA Macro를 쓰려고 합니다.
코드 상에는 문제가 없는 것 같은데 파일 이름과 폴더 이름이 한글인 것이 문제가 되나요?
그렇다면 다 영어 이름으로 바꾸는 것 외에 다른 해결 방법이 없을까요?

Microsoft 365 및 Office | 기타
댓글 0개 설명 없음

답변 2개

정렬 기준: 가장 유용함
  1. Kimberly Olaño 23,410 평판 포인트
    2025-11-06T22:19:02.8033333+00:00

    Okay, try this for macOS version.

    Sub OpenFile_MacCompatible()

    Dim filePath As String

    ' Use macOS native file dialog

    On Error Resume Next

    filePath = MacScript("POSIX path of (choose file with prompt ""Select a Word file to open:"")")

    On Error GoTo 0

    ' Check if user canceled

    If filePath <> "" Then

    Documents.Open FileName:=filePath

    Else

    MsgBox "No file selected.", vbInformation

    End If

    End Sub

    이 대답이 도움이 되었나요?

    댓글 0개 설명 없음

  2. Kimberly Olaño 23,410 평판 포인트
    2025-11-05T23:43:03.6+00:00

    Thanks for the details, Michael! Yes this can absolutely be an issue on macOS VBA, especially when working with file paths containing Korean.

    I suggest you use the macOS FileDialog object in Word VBA

    If you use the built-in dialog instead of hardcoding the path, Word handles encoding internally:

    Dim fd As FileDialog

    Dim chosenFile As String

    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    If fd.Show = -1 Then

    chosenFile = fd.SelectedItems(1)

    Documents.Open FileName:=chosenFile

    End If

    This method usually works fine with Korean file names.

    See if this helps. If you need further assistance just let me know.

    Best regards,

    Kimberly

    이 대답이 도움이 되었나요?


답변

질문 작성자는 답변을 '승인됨'으로 표시하고, 중재자는 답변을 '추천됨'으로 표시할 수 있습니다. 이를 통해 사용자는 해당 답변이 작성자의 문제를 해결했다는 것을 알 수 있습니다.