[AccessD] Dialog Box for Creating .txt tables

Stuart McLachlan stuart at lexacorp.com.pg
Tue Mar 17 20:21:53 CDT 2009


Using the  Windows API

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

      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 SaveFileName() as String
         Dim OpenFile As OPENFILENAME
         Dim lReturn As Long
         Dim sFilter As String
         OpenFile.lStructSize = Len(OpenFile)
         OpenFile.hwndOwner = Me.hWnd
         OpenFile.hInstance = 0
         sFilter = "" & Chr(0)
         OpenFile.lpstrFilter = sFilter
         OpenFile.nFilterIndex = 1
         OpenFile.lpstrFile = String(257, 0)
         OpenFile.nMaxFile = Len(OpenFile.lpstrFile) - 1
         OpenFile.lpstrFileTitle = OpenFile.lpstrFile
         OpenFile.nMaxFileTitle = OpenFile.nMaxFile
         OpenFile.lpstrInitialDir = "C:\"
         OpenFile.lpstrTitle = "Select File"
         OpenFile.flags = 0
         lReturn = GetSaveFileName(OpenFile)
         SaveFilename = Left$(OpenFile.lpstrFile, InStr(OpenFile.lpstrFile, Chr$(0)) - 1)
End Function


> > Subject: [AccessD] Dialog Box for Creating .txt tables
> >
> > I have an Access application that creates a text (.txt) table using
> > DoCmd.TransferText.
> >
> > In this application, I would like to display a windows dialog box showing
> > "Save in;" and "File name:" that would allow the user to navigate to the
> > directory where the table would be located and designate file name to be
> > used.
> > (Similar to the dialog box that you see when you do a file save as in
> > Microsoft word etc.)
> >
> > Is it possible to do this in Access?
> >
> > If so, would some one tell me where I can find information and examples.
> > --





More information about the AccessD mailing list