Mac에서이 작업을 더 잘 수행하려면 Apple Script를 사용해야한다고 생각합니다. 다음 코드를 사용하면 함수에서 배열로 반환 된 텍스트 파일을 선택할 수 있습니다. 다른 파일 형식을 반환하고 디렉토리를 선택하도록 Apple Script를 수정할 수 있습니다.이 파일을 남겨 두겠습니다.
함수를 호출하고 메시지의 모든 파일과 상자를 표시하는 코드 :
Sub GetTextFilesOnMac()
Dim vFileName As Variant
'Call the function to return the files
vFileName = Select_File_Or_Files_Mac
'If it's empty then the user cancelled
If IsEmpty(vFileName) Then Exit Sub
'Loop through all the files specified
For ii = LBound(vFileName) To UBound(vFileName)
MsgBox vFileName(ii)
Next ii
End Sub
그리고 애플 스크립트 작업 수행 기능 : 마지막으로
Function Select_File_Or_Files_Mac() As Variant
'Uses AppleScript to select files on a Mac
Dim MyPath As String, MyScript As String, MyFiles As String, MySplit As Variant
'Get the documents folder as a default
On Error Resume Next
MyPath = MacScript("return (path to documents folder) as String")
'Set up the Apple Script to look for text files
MyScript = "set applescript's text item delimiters to "","" " & vbNewLine & _
"set theFiles to (choose file of type " & " {""public.TEXT""} " & _
"with prompt ""Please select a file or files"" default location alias """ & _
MyPath & """ multiple selections allowed true) as string" & vbNewLine & _
"set applescript's text item delimiters to """" " & vbNewLine & _
"return theFiles"
'Run the Apple Script
MyFiles = MacScript(MyScript)
On Error GoTo 0
'If there are multiple files, split it into an array and return the results
If MyFiles <> "" Then
MySplit = Split(MyFiles, ",")
Select_File_Or_Files_Mac = MySplit
End If
End Function
, 그것은 될 수있는 Word 문서 만 지정하려면 public.TEXT
을 com.microsoft.word.doc
으로 바꾸십시오. 그러나 .docx
또는 .docm
개의 파일은 허용되지 않습니다. 이 경우 각각 org.openxmlformats.wordprocessingml.document
및 org.openxmlformats.wordprocessingml.document.macroenabled
을 사용해야합니다. 자세한 내용은 https://developer.apple.com/library/mac/#documentation/FileManagement/Conceptual/understanding_utis/understand_utis_conc/understand_utis_conc.html
Mac 용 VBA에 대해서는 잘 모르지만 다음 [post] (http://stackoverflow.com/questions/15518682/to-add)에서 살펴볼 수 있습니다. -header-and-footer-for-many-word-documents/15520412 # 15520412) Word 2010의 'msoFileDialogFilePicker'에 대한 정확한 구조를 제시합니다. –
고마워요, 그게 내 추가 기능을 현재 작성한 것입니다. FileDialog는 Word 2011에서 "사용자 정의 유형"오류를 발생시킵니다. 따라서 다른 것으로 불리거나이 대화 상자는 콘텐츠 모델을 통해 액세스 할 수 없습니다. – Christina