programing

Windows 탐색기를 열고 파일 선택

linuxpc 2023. 4. 26. 23:02
반응형

Windows 탐색기를 열고 파일 선택

vba 양식에서 Windows 탐색기 창을 열고 특정 파일로 이동한 후 선택하여 파일 이름을 텍스트 상자에 넣을 수 있는 방법이 있습니까?

다음 스니펫을 확인하십시오.

Private Sub openDialog()
    Dim fd As Office.FileDialog

    Set fd = Application.FileDialog(msoFileDialogFilePicker)

   With fd

      .AllowMultiSelect = False

      ' Set the title of the dialog box.
      .Title = "Please select the file."

      ' Clear out the current filters, and add our own.
      .Filters.Clear
      .Filters.Add "Excel 2003", "*.xls"
      .Filters.Add "All Files", "*.*"

      ' Show the dialog box. If the .Show method returns True, the
      ' user picked at least one file. If the .Show method returns
      ' False, the user clicked Cancel.
      If .Show = True Then
        txtFileName = .SelectedItems(1) 'replace txtFileName with your textbox

      End If
   End With
End Sub

저는 이것이 당신이 요구하는 것이라고 생각합니다.

언급URL : https://stackoverflow.com/questions/10304989/open-windows-explorer-and-select-a-file

반응형