输入框中的浏览按钮以查找Excel2007 Vba文件 [英] browse button in input box to find file Excel2007 Vba
问题描述
我需要在输入框中使用浏览按钮来查找文件-VBA-EXCEL宏] [1]
需要通过浏览按钮而不是在输入框中键入来查找文件夹路径 有可能吗?
| ------------------- |
| ------------------- |浏览 通过单击一个单元格,它应该请求文件浏览. 不应手动编辑.我的意思是,我想锁定特定的单元格.并且只能通过宏进行编辑.
您可以使用它来查找文件.如果需要,请修改过滤器.变量fldr
将包含您的数据.然后,您可以将文本框设置为该值.
Sub File_Picker()
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.Filters.Add "Text", "*.txt", 1
.InitialFileName = ActiveWorkbook.Path & "\"
.Show
If .SelectedItems.Count = 0 Then GoTo 1
fldr = .SelectedItems(1)
End With
End Sub
或:
Sub Folder_Picker()
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = ActiveWorkbook.Path & "\"
.Show
If .SelectedItems.Count = 0 Then GoTo 1
fldr = .SelectedItems(1)
End With
End Sub
在我的GitHub >
I need the browse button in input box to find file - VB A - EXCEL Macro][1]
need to find the folder path via browse button instead of typing in input box is it possible?
|-------------------|
|-------------------| Browse by clicking a cell it should ask for file browse. should not be edited manually. i mean , i want to lock the particular cell locked. and only able to edit via macro.
You can use this to find a file. Modify the filter if you need to. the variable fldr
will have your data. Then you can set your textbox to that value.
Sub File_Picker()
With Application.FileDialog(msoFileDialogFilePicker)
.Filters.Clear
.Filters.Add "Text", "*.txt", 1
.InitialFileName = ActiveWorkbook.Path & "\"
.Show
If .SelectedItems.Count = 0 Then GoTo 1
fldr = .SelectedItems(1)
End With
End Sub
or:
Sub Folder_Picker()
With Application.FileDialog(msoFileDialogFolderPicker)
.InitialFileName = ActiveWorkbook.Path & "\"
.Show
If .SelectedItems.Count = 0 Then GoTo 1
fldr = .SelectedItems(1)
End With
End Sub
I have more helpful pieces of code like this at My GitHub
这篇关于输入框中的浏览按钮以查找Excel2007 Vba文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!