gpt4 book ai didi

database - 微软 Access : Can't change the file type in the Save As dialog box

转载 作者:搜寻专家 更新时间:2023-10-30 21:36:28 24 4
gpt4 key购买 nike

我有一个在 access 2003 中创建的 .mdb 文件,我想将其转换为 access 2007 .accdb但是当我转到“另存为”对话框时,它只允许我将文件保存为当前格式 (.mdb),并且下拉框中没有任何其他文件格式。

当我创建一个新的 .accdb 并尝试将其另存为 2003 .mdb 文件时,同样的事情发生了。在“另存为文件格式”下拉框中,除了 .accdb 之外我什么都看不到。

我可能可以运行 VBA 代码来保存为我想要的文件格式,但这不是最佳选择。

有人知道解决方案是什么吗?

谢谢, jack

最佳答案

'PUT THIS IN A STANDARD CLASS MODULE FIRST

Option Compare Database
Private mstrFileName As String
Private mblnStatus As Boolean
'Declare needed functions

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

Private Declare Function GetSaveFileName Lib "comdlg32.dll" Alias "GetSaveFileNameA" _
(pOpenfilename As OPENFILENAME) As Long

'Declare OPENFILENAME custom Type

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

'Function needed to call the "Save As" dialog

Public Function SaveFileDialog(lngFormHwnd As Long, _
lngAppInstance As Long, strInitDir As String, _
strFileFilter As String) As Long

Dim SaveFile As OPENFILENAME
Dim X As Long

If IsMissing(strFileName) Then strFileName = ""

With SaveFile
.lStructSize = Len(SaveFile)
.hwndOwner = lngFormHwnd
.hInstance = lngAppInstance
.lpstrFilter = strFileFilter
.nFilterIndex = 1
.lpstrFile = String(257, 0)
'Use for a Default File SaveAs Name - [UD]
'.lpstrFile = "testfile.txt" & String(257 - Len("testfile.txt"), 0)
.nMaxFile = Len(SaveFile.lpstrFile) - 1
.lpstrFileTitle = SaveFile.lpstrFile
.nMaxFileTitle = SaveFile.nMaxFile
.lpstrInitialDir = strInitDir
.lpstrTitle = "Enter a Filename to Save As" '[UD]
.Flags = 0
.lpstrDefExt = ".xls" 'Sets default file extension to Excel,
'in case user does not type it - [UD]
End With

X = GetSaveFileName(SaveFile)

If X = 0 Then
mstrFileName = "none"
mblnStatus = False
Else
mstrFileName = Trim(SaveFile.lpstrFile)
mblnStatus = True
End If
End Function
Public Property Let GetName(strName As String)
mstrFileName = strName
End Property
Public Property Get GetName() As String
GetName = mstrFileName
End Property
Public Property Let GetStatus(blnStatus As Boolean)
mblnStatus = blnStatus
End Property
Public Property Get GetStatus() As Boolean
GetStatus = mblnStatus
End Property


'THEN WE'LL CALL IT LIKE

Private Sub cmdTest_Click()
On Error GoTo Err_cmdTest_Click
Dim cDlg As New CommonDialogAPI 'Instantiate CommonDialog
Dim lngFormHwnd As Long
Dim lngAppInstance As Long
Dim strInitDir As String
Dim strFileFilter As String
Dim lngResult As Long

lngFormHwnd = Me.Hwnd 'Form Handle
lngAppInstance = Application.hWndAccessApp 'Application Handle
strInitDir = "C:\" 'Initial Directory - [UD]

'Create any Filters here - [UD]

strFileFilter = "Excel Files (*.xls)" & Chr(0) & "*.xls" & Chr(0) & _
"ALL Files (*.*)" & Chr(0) & "*.* & Chr(0)"
'"Text Files (*.csv, *.txt)" & _
'Chr(0) & "*.csv; *.txt" & Chr(0)

lngResult = cDlg.SaveFileDialog(lngFormHwnd, _
lngAppInstance, strInitDir, strFileFilter)

If cDlg.GetStatus = True Then
MsgBox "You chose the Filename of: " & cDlg.GetName 'Retrieve Filename - [UD]
Else
MsgBox "No file chosen." '[UD]
End If

Exit_cmdTest_Click:
Exit Sub

Err_cmdTest_Click:
MsgBox Err.Description, vbExclamation, "Error in cmdTest_Click()"
Resume Exit_cmdTest_Click
End Sub

关于database - 微软 Access : Can't change the file type in the Save As dialog box,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/7548678/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com