Office中国论坛/Access中国论坛

标题: 需要加什么才能调用GetSaveAsFilename [打印本页]

作者: fjcas    时间: 2008-5-7 12:20
标题: 需要加什么才能调用GetSaveAsFilename
需要加什么才能调用GetSaveAsFilenameaccess 中 需要加什么才能调用GetSaveAsFilename ?求高人指点

以下是网上搜的调用 GetOpenFileName 的代码

Declare Function GetOpenFileName Lib "comdlg32.dll" Alias "GetOpenFileNameA" (pOpenfilename As OPENFILENAME) As Boolean
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 Sub Filename_Click()
On Error GoTo Err_Command5_Click
   
    Dim ofn As OPENFILENAME
   Dim rtn As String
   ofn.lStructSize = Len(ofn)
   ofn.hwndOwner = Me.hwnd
   ofn.lpstrFilter = "Êý¾Ý¿âÎļþ (*.mdb)" & vbNullChar & "*.mdb"
   ofn.lpstrFile = Space(254)
   ofn.nMaxFile = 255
   ofn.lpstrFileTitle = Space(254)
   ofn.nMaxFileTitle = 255
   ofn.lpstrInitialDir = CurrentProject.Path
   ofn.lpstrTitle = "×¼±¸ÉÏ´«µÄÊý¾ÝÎļþΪ"
   ofn.flags = 6148
   rtn = GetOpenFileName(ofn)

   If rtn = True Then
     
      FileName.Text = ofn.lpstrFile
     
      OK.Enabled = True
   Else
       FileName.Text = ""
   End If
   
   
Exit_Command5_Click:
    Exit Sub
Err_Command5_Click:
    MsgBox Err.Description
   
    FileName.SetFocus
    FileName.SelStart = 0
    FileName.SelLength = 100
   
    Resume Exit_Command5_Click
End Sub
作者: tmtony    时间: 2008-5-7 12:25
API那段定义需要放在模块中,且要定义为公共




欢迎光临 Office中国论坛/Access中国论坛 (http://www.office-cn.net/) Powered by Discuz! X3.3