如何使用 VBA 在 Application.FileDialog 中创建自定义链接?

发布于 2024-10-01 22:16:00 字数 999 浏览 5 评论 0原文

我正在尝试使用 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

这是我试图完成的任务的屏幕截图?

alt text

有任何指示吗?

谢谢,

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?

alt text

Any pointers?

Thanks,

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

新雨望断虹 2024-10-08 22:16:00

它应该是可行的,但您需要从访问文件对话框切换,并使用 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!

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文