|
如何将文件有只有MDB 变成WORD EXCEL 和MDB?
Public Function dlgGetFile1(Optional strInitDir As String, Optional strFilter As String = "access files(*.mdb)" & vbNullChar & "*.mdb" & vbNullChar & vbNullChar, _
Optional intFilterIndex As Integer = 1, Optional strDefaultExt As String = "mdb", Optional strfilename = "", Optional strDialogTitle As String = "打开清单预算文件", _
Optional hwnd As Long = -1, Optional fOpenFile As Boolean = True, Optional ByRef lngFlags As Long = 0) As Variant '文件函数
Dim ofn As OPENFILENAME '定义的数组变量
Dim strFileTitle As String
Dim fResult As Boolean
If strInitDir = "" Then '自变量
strInitDir = CurDir
End If
If hwnd = -1 Then '自变量
hwnd = Application.hWndAccessApp 'ACCESS句柄
End If
strfilename = strfilename & String(255 - Len(strfilename), 0) '同下
strFileTitle = String(255, 0) ' string函数。在字符串0中取255个字符????
With ofn ' OEENFILENAME的一个事例
.lngStructSize = Len(ofn)
.hwndOwner = hwnd
.strFilter = strFilter
.intFilterIndex = intFilterIndex
.strFile = strfilename
.intMaxFile = Len(strfilename)
.strFileTitle = strFileTitle
.intMaxFileTitle = Len(strFileTitle)
.strTitle = strDialogTitle
.lngFlags = lngFlags
.strDefExt = strDefaultExt
.hInstance = 0
.strCustomFilter = String(255, 0)
.intMaxCustFilter = 255
.lngfnHook = 0
End With
If fOpenFile Then '上述API函数自变量
fResult = GetOpenFileName(ofn) '上面新定义的变量
Else
fResult = GetSaveFileName(ofn)
End If
If fResult Then
lngFlags = ofn.lngFlags '对API函数自便量赋值
dlgGetFile = TrimNull(ofn.strFile) '本函数值
Else
dlgGetFile = TrimNull(ofn.strFile)
End If
End Function
|
|