我在Windows XP上运行的打开/保存对话框不再适用于我的Windows 7 64位。我听说'MSComDlg.CommonDialog'与64位不兼容。这是我的旧代码:
' Sub to show open/save dialog
SUB OpenSave (varOpenSaveInputBox, varOpenSaveType, varOpenSaveFilter)
' Create object
SET objComDlg32 = CreateObject("MSComDlg.CommonDialog")
' Set memory buffer
objComDlg32.MaxFileSize = 260
' Set filter
objComDlg32.Filter = varOpenSaveFilter
' Show dialog
IF varOpenSaveType = 0 Then
objComDlg32.ShowOpen
ELSE
objComDlg32.ShowSave
End IF
' Get filename from dialog
strOpenSave = objComDlg32.FileName
' Check IF dialog is cancelled
IF strOpenSave <> vbNullString Then
' Set to variable
objOpenSave.SetContent strOpenSave, TRUE
End If
END SUB
如果你对答案更具体,而不是“使用它!”,我将非常感激。 DLL和OCX并不是我的强项。感谢。
答案 0 :(得分:0)
这是VBA,但它可能足以让您指向正确的方向。 3声明了您要打开的对话框类型。您可以在此处找到更多信息:http://msdn.microsoft.com/en-us/library/office/ff865284.aspx。
Sub FileSelect (Multi as Boolean)
' Set Dlg = Application.FileDialog(msoFileDialogFilePicker)
Set Dlg = Access.Application.FileDialog(3)
With Dlg
.Title = "Select the file you want to open"
.AllowMultiSelect = Multi
If .Show = -1 Then
txtFilePath = .InitialFileName
Else
Exit Function
End If
End With
FileSelect = Dlg.SelectedItems(1)
End Function
答案 1 :(得分:0)
我正在使用此代码,该代码是我在互联网上某个地方找到的(甚至可能在StackOverflow上。我也不记得了)
TransactionScope