English 中文(简体)
是否有关于2010年准入的公开档案辩证?
原标题:Is there an Open File dialog for Access 2010 64bit?

我怎样才能获得2010年64比特的开放文件方言。 通常,我将使用共同的方言控制,但这是32比照,无法在2010年获得64比特的情况下使用。

最佳回答

这种伪装具有一种工具,可生成64比方尺的代码,用于开启档案。 这是免费的。

这是唯一的工作。

问题回答

你们可以使用档案诊断中的建筑。 自2003年访问以来,情况一直如此。

Dim f    As FileDialog 
Set f = Application.FileDialog(msoFileDialogFilePicker) 
f.Show 
MsgBox "file choose was " & f.SelectedItems(1) 

如果你希望:

以上需要: 微软公司14.0 目标图书馆

If you remove the reference to the 14.0 object library, then the following code will work without any references:

Dim f    As Object 
Set f = Application.FileDialog(3) 
f.AllowMultiSelect = True 
f.Show 

MsgBox "file choosen = " & f.SelectedItems.Count 

因此,以上在2003年以后的操作时间或定期版本中工作,并且还在2010年的32或64个轨道版本上工作。

I ve never used a control for the open File dialog as it s just a wrapper for the API call anyhow. Call the standard Windows File Open/Save dialog box In addition there can be distribution and versioning problems with controls so I do my best to avoid them.

长期以来,我一直在处理这个问题。

以上所述的一切都可行,但最后一点是,根据外国军队的声明,你需要改变。

.lStructSize = Len(ofn)

纽约总部

.lStructSize = LenB(ofn)

那么,所有东西都是行之有效的。

First of all, the "CommonDialog Class" doesn t even appear to work on a 32-bit version of Office. It gives the same OleDb error. As one of the commenters points out, this isn t the control you should be using. And while there might be another ActiveX control you could use, there s really no guarantee that it will be available on every machine that you want to deploy your database on. My dev box has Visual Studio 6, VS 2008, and VS 2010 on it, in addition to Office and other programs, all of which provide ActiveX DLLs that a typical user could not be expected to have. Additionally, many of these libraries are not redistributable, or pose unique installation hurdles that may simply not be worth the trouble.

www.un.org/Depts/DGACM/index_spanish.htm 到目前为止,最简单、最普遍的解决办法是把“开放方言”从“窗户”转播。 它位于 comdlg32.dll,每版本的视窗都可供选择,而且不会把任何附属于 comdlg32.ocx。 该系统还提供比使用主动X控制更好的性能,因为它没有要求增加一个模块,以装上记忆。

所需要的法典也非常复杂。 http://msdn.microsoft.com/en-us/library/ms646927.aspx” rel=“nofollow”GetOpenFileName,创建开放方言箱。 该表仅涉及一个参数,即OPENFILENAME structure,其中载有用于启动方言箱的信息,以及接收用户选择的档案。 因此,你也需要宣布这一结构。 VBA的法典将考虑这样的内容:

Private Type OPENFILENAME
    lStructSize As Long
    hwndOwner As Long
    hInstance As Long
    lpstrFilter As String
    lpstrCustomFilter As String
    nMaxCustFilter As Long
    nFilterIndex As Long
    lpstrFile As String
    nMaxFile As Long
    lpstrFileTitle As String
    nMaxFileTitle As Long
    lpstrInitialDir As String
    lpstrTitle As String
    flags As Long
    nFileOffset As Integer
    nFileExtension As Integer
    lpstrDefExt As String
    lCustData As Long
    lpfnHook As Long
    lpTemplateName As String
End Type

Private Declare Function GetOpenFileName Lib "comdlg32.dll" _
    Alias "GetOpenFileNameA" (ByRef lpofn As OPENFILENAME) As Long

另外,还有两条固定不变的标志,可以把直言语当作特定行为。 完整无遗,此处列出完整清单:

Private Const OFN_ALLOWMULTISELECT As Long = &H200
Private Const OFN_CREATEPROMPT As Long = &H2000
Private Const OFN_ENABLEHOOK As Long = &H20
Private Const OFN_ENABLETEMPLATE As Long = &H40
Private Const OFN_ENABLETEMPLATEHANDLE As Long = &H80
Private Const OFN_EXPLORER As Long = &H80000
Private Const OFN_EXTENSIONDIFFERENT As Long = &H400
Private Const OFN_FILEMUSTEXIST As Long = &H1000
Private Const OFN_HIDEREADONLY As Long = &H4
Private Const OFN_LONGNAMES As Long = &H200000
Private Const OFN_NOCHANGEDIR As Long = &H8
Private Const OFN_NODEREFERENCELINKS As Long = &H100000
Private Const OFN_NOLONGNAMES As Long = &H40000
Private Const OFN_NONETWORKBUTTON As Long = &H20000
Private Const OFN_NOREADONLYRETURN As Long = &H8000&
Private Const OFN_NOTESTFILECREATE As Long = &H10000
Private Const OFN_NOVALIDATE As Long = &H100
Private Const OFN_OVERWRITEPROMPT As Long = &H2
Private Const OFN_PATHMUSTEXIST As Long = &H800
Private Const OFN_READONLY As Long = &H1
Private Const OFN_SHAREAWARE As Long = &H4000
Private Const OFN_SHAREFALLTHROUGH As Long = 2
Private Const OFN_SHAREWARN As Long = 0
Private Const OFN_SHARENOWARN As Long = 1
Private Const OFN_SHOWHELP As Long = &H10
Private Const OFS_MAXPATHNAME As Long = 260

And for convenience, I ve wrapped this whole mess inside of a helper function that you can call from within VBA. It accepts as parameters the properties you will most commonly need to set for the open file dialog, handles calling the Windows API itself, and then returns either the full path to the file selected by the user, or an empty string (vbNullString) if the user clicked the Cancel button. You can test the return value in the calling code to determine which course of action to take.

 This function shows the Windows Open File dialog with the specified
  parameters, and either returns the full path to the selected file,
  or an empty string if the user cancels.
Public Function OpenFile(ByVal Title As String, ByVal Filter As String, _
    ByVal FilterIndex As Integer, ByVal StartPath As String, _
    Optional OwnerForm As Form = Nothing) As String

     Create and populate an OPENFILENAME structure
     using the specified parameters
    Dim ofn As OPENFILENAME
    With ofn
        .lStructSize = Len(ofn)
        If OwnerForm Is Nothing Then
            .hwndOwner = 0
        Else
            .hwndOwner = OwnerForm.Hwnd
        End If
        .lpstrFilter = Filter
        .nFilterIndex = FilterIndex
        .lpstrFile = Space$(1024) & vbNullChar & vbNullChar
        .nMaxFile = Len(ofn.lpstrFile)
        .lpstrFileTitle = vbNullChar & Space$(512) & vbNullChar & vbNullChar
        .nMaxFileTitle = Len(.lpstrFileTitle)
        .lpstrInitialDir = StartPath & vbNullChar & vbNullChar
        .lpstrTitle = Title
        .flags = OFN_FILEMUSTEXIST
    End With

     Call the Windows API function to show the dialog
    If GetOpenFileName(ofn) = 0 Then
         The user pressed cancel, so return an empty string
        OpenFile = vbNullString
    Else
         The user selected a file, so remove the null-terminators
          and return the full path
        OpenFile = Trim$(Left$(ofn.lpstrFile, Len(ofn.lpstrFile) - 2))
    End If
End Function

由此而来的是漫长的。 有许多声明需要复制并贴上模块,但你实际上必须处理的接口非常简单。 这里是你在法典中如何实际利用这一工具来显示公开档案辩证,并找到档案:

Public Sub DoWork()
     Set the filter string (patterns) for the open file dialog
    Dim strFilter As String
    strFilter = "Text Files (*.txt)" & vbNullChar & "*.txt*" & vbNullChar & _
                "All Files (*.*)" & vbNullChar & "*.*" & vbNullChar & vbNullChar

     Show the open file dialog with the custom title, the filters specified
      above, and starting in the root directory of the C: drive.
    Dim strFileToOpen As String
    strFileToOpen = OpenFile("Choose a file to open", strFilter, 0, "C:")

     See if the user selected a file
    If strFileToOpen = vbNullString Then
        MsgBox "The user pressed the Cancel button."
    Else
        MsgBox "The user chose to open the following file: " & _
               vbNewLine & strFileToOpen 
    End If
End Sub

<><>> 撰写和测试这一解决办法的最长部分实际上试图找到如何向世贸总会编辑开放和撰写进入的宏观文件。 Ribbon可能是一种伟大的发明,对使用菜单的人来说,是“Paste”和“Save”的。 我每天使用软件,我仍然无法发现。 [/rant]

我刚刚在《2013年Excel》的64个轨道版本中解决这一问题。

A combination of...

  1. Using the LongPtr data type for 3 of the items (hwndOwner, hInstance, lpfnHook) in the OPENFILENAME structure passed to GetOpenFileNameA
  2. Replacing the Len function with the LenB function when obtaining the size of the OPENFILENAME structure (as mentioned by Max Albanese)

...did the trick, thanks to guidance documented here: https://gpgonaccess.blogspot.co.uk/2010/03/work-in-progress-and-64-bit-vba.html





相关问题
Handling no results for docmd.applyfilter

I have an Access app where I use search functionality. I have a TextBox and a Search Button on the form, and it does a wildcard search of whatever the user enters in the TextBox, and displays the ...

Outlook 2007 CommandBarControl.Execute won t work

I recently switched to Outlook 2007 and noticed that my VBA-macros won t work. I use the following code to open a new appointment-item (and fill it automatically). It worked perfect in Outlook 2003, ...

Connecting to Oracle 10g with ODBC from Excel VBA

The following code works. the connection opens fine but recordset.recordCount always returns -1 when there is data in the table. ANd If I try to call any methods/properties on recordset it crashes ...

MS Access: list macro from VBA

I have to deal with a few macros (not VBA) in an inherited Access application. In order to document them, I would like to print or list the actions in those macros, but I am very dissatisfied by ...

热门标签