如何使用 VBA 在 Application.FileDialog 中创建自定义链接?
我正在尝试使用 VBA 中的 FileDialog 构造来显示用户可能想要打开的可用文件列表。我还想引导用户访问一些常见的文件夹,他们通常会在其中找到他们正在寻找的内容类型。到目前为止,我还没有找到一种方法来在文件对话框的左侧放置一个链接,他们可以在其中单击以跳转到特定位置。
我希望有一种方法可以在调用 FileDialog 方法时执行此操作,如下面所示的示例,其中我使用了 fd.AddLinkMethod“
。
Private Function GetLocation() As String
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.ButtonName = "Open"
fd.Title = "Select File To Open"
fd.InitialView = msoFileDialogViewTiles
fd.AddLinkMethod "<path goes here>"
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
GetLocation= FormatPath(vrtSelectedItem)
Next vrtSelectedItem
End If
End With
Set fd = Nothing
End Function
这是我试图完成的任务的屏幕截图?
有任何指示吗?
谢谢,
I am attempting to use the FileDialog construct in VBA to display a list of available files the user may want to open. I would like to also steer the user towards some common folders in which they typically will find the type of content they are looking for. So far I have come short on locating a method to place a link on the left side of the FileDialog box in which they could click to jump to a specific location.
I am hoping there is a means of doing this while calling the FileDialog methods like an example shown below where I have used the fd.AddLinkMethod "<path goes here>"
.
Private Function GetLocation() As String
Dim fd As FileDialog
Dim vrtSelectedItem As Variant
Set fd = Application.FileDialog(msoFileDialogOpen)
fd.ButtonName = "Open"
fd.Title = "Select File To Open"
fd.InitialView = msoFileDialogViewTiles
fd.AddLinkMethod "<path goes here>"
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
GetLocation= FormatPath(vrtSelectedItem)
Next vrtSelectedItem
End If
End With
Set fd = Nothing
End Function
Here is a screenshot of what I am attempting to accomplish?
Any pointers?
Thanks,
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
它应该是可行的,但您需要从访问文件对话框切换,并使用 Windows API 中的 Windows 通用对话框。 ( http://support.microsoft.com/kb/161286 ) 那么有几种方法修改本文中指出的链接 ( http://www.makeuseof.com/tag/4-more-ways-to-customize-common-dialog-open-in-windows-xp/ )。不是最优雅的,但它应该可以工作。祝你好运!
It should be do-able, but you will need to switch from the access filedialog, and use the Windows Common Dialog from the windows API. ( http://support.microsoft.com/kb/161286 ) Then there are a few ways to modify the links that are pointed out in this article ( http://www.makeuseof.com/tag/4-more-ways-to-customize-common-dialog-open-in-windows-xp/ ). Not the most elegant, but it should work. Goodluck!