2012-04-24 15 views
15

क्या एक वीबीए फॉर्म से विंडोज एक्सप्लोरर विंडो खोलने का कोई तरीका है, किसी विशिष्ट फ़ाइल पर नेविगेट करें और इसे चुनें ताकि फ़ाइल का नाम किसी टेक्स्ट बॉक्स में रखा जा सके? इस स्निपेट बाहरओपन विंडोज एक्सप्लोरर और फ़ाइल का चयन करें

+3

वीबीए एक्सेल में जादू कुंजी 'एफ 1' दबाएं और' एप्लिकेशन.गेट ओपनफिलनाम 'की खोज करें;) –

उत्तर

46

की जांच:

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 

मुझे लगता है कि यह आपके लिए क्या पूछ रहे हैं है।

+13

आप एक सुंदर इंसान हैं। – Quintis555

संबंधित मुद्दे