访问附件对话窗口

时间:2011-05-13 15:20:49

标签: ms-access

我正在尝试使用表单中的“命令”按钮打开以下链接中所示的窗口。是否有人可以告诉我如何做到这一点?

http://www.utteraccess.com/forum/Launching-Attachments-Dia-t1652872.html

提前谢谢!

2 个答案:

答案 0 :(得分:1)

我不确定您是否可以调用此特定对话框,但您可以执行的是使用带有FilePicker选项的通用FileDialog。然后保存使用该文件的路径并将特定文件复制到共享位置(可能也是存储后端的位置)。然后在表格中,保存到新位置的路径。

帮助中解释了使用filedialog:

Sub Main()

    'Declare a variable as a FileDialog object.
    Dim fd As FileDialog

    'Create a FileDialog object as a File Picker dialog box.
    Set fd = Application.FileDialog(msoFileDialogFilePicker)

    'Declare a variable to contain the path
    'of each selected item. Even though the path is aString,
    'the variable must be a Variant because For Each...Next
    'routines only work with Variants and Objects.
    Dim vrtSelectedItem As Variant

    'Use a With...End With block to reference the FileDialog object.
    With fd

        'Use the Show method to display the File Picker dialog box and return the user's action.
        'The user pressed the button.
        If .Show = -1 Then

            'Step through each string in the FileDialogSelectedItems collection.
            For Each vrtSelectedItem In .SelectedItems

                'vrtSelectedItem is aString that contains the path of each selected item.
                'You can use any file I/O functions that you want to work with this path.
                'This example displays the path in a message box.
                MsgBox "The path is: " & vrtSelectedItem

            Next vrtSelectedItem
        'The user pressed Cancel.
        Else
        End If
    End With

    'Set the object variable to Nothing.
    Set fd = Nothing

End Sub 

通过谷歌,我遇到了this (old) topic,给出了更多理由不在表格中使用附件类型(更新,插入,......查询将不会那么容易,即。)。

由于我遵循David.W.Fenton对我的回答的评论,我还建议阅读following topic on SO。特别是Mitch Weath的回答提供了有关在Open文件对话框中使用Win32 API的一些额外信息。

答案 1 :(得分:0)

我找到的答案非常简单,以至于我必须假设第一次发布问题时它不可用。但至少从 2017 年开始,您可以使用:

Private Sub MyAttachment_GotFocus()
    RunCommand acCmdManageAttachments
End Sub