Isa*_*ses 9 forms ms-access file-browser
我想在MS Access 2007表单中添加一个"浏览"按钮,它将打开一个标准的Windows文件浏览器(作为模式窗口),并允许用户选择一个目录.当用户退出该浏览器时,应将所选目录的路径写入Access窗体中的文本框.
最好的方法是什么?有原生的Access方式吗?
Han*_*sUp 12
创建一个使用的功能Application.FileDialog.的FileDialog是模态.
如果用户的文件夹选择为一个,则此函数将返回该用户的文件夹选择;如果用户单击取消,则返回空字符串FileDialog.
Public Function FolderSelection() As String
Dim objFD As Object
Dim strOut As String
strOut = vbNullString
'msoFileDialogFolderPicker = 4
Set objFD = Application.FileDialog(4)
If objFD.Show = -1 Then
strOut = objFD.SelectedItems(1)
End If
Set objFD = Nothing
FolderSelection = strOut
End Function
Run Code Online (Sandbox Code Playgroud)
我想你可以在命令按钮的点击事件中使用该功能.
Dim strChoice As String
strChoice = FolderSelection
If Len(strChoice) > 0 Then
Me.TextBoxName = strChoice
Else
' what should happen if user cancelled selection?
End If
Run Code Online (Sandbox Code Playgroud)
如果您担心Microsoft FileDialog有一天可能会从Office中删除该对象,则可以使用Windows API方法:BrowseFolder Dialog.
| 归档时间: |
|
| 查看次数: |
38754 次 |
| 最近记录: |