Save As Dialog

Taff

Registered User.
Local time
Today, 05:09
Joined
Feb 3, 2004
Messages
158
Save As Dialogue

Hi all,

Have a form with a command button on which used the docmd.transfertext command.

Was wondering if when clicked I can have a prompt where the user chooses a save location.

Is this possible at all?


Thanks All

Anthony
 
Save as Dialog

Anthony,

It seems that you have to provide the FileName argument of the TransferText method from within VBA. So you will have to collect the information prior to calling the method. (I believe if you use a macro and do not provide a FileName/Destination you will be prompted to do so)

You could have the button-click event respond by calling the previously mentioned API call to the Common Dialog Control or you could simply ask for the destination in a form of your own. Then call the TransferText method.

Regards,
 
Thanks Ghuson & aaron.orrell,

I looked at the following:-

API: BrowseFolder Dialog
http://www.mvps.org/access/api/api0002.htm

I have put this in a module and called it from a command button and it works fine:-

Code:
'************** Code Start **************
'This code was originally written by Terry Kreft.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code courtesy of
'Terry Kreft

Private Type BROWSEINFO
  hOwner As Long
  pidlRoot As Long
  pszDisplayName As String
  lpszTitle As String
  ulFlags As Long
  lpfn As Long
  lParam As Long
  iImage As Long
End Type

Private Declare Function SHGetPathFromIDList Lib "shell32.dll" Alias _
            "SHGetPathFromIDListA" (ByVal pidl As Long, _
            ByVal pszPath As String) As Long
            
Private Declare Function SHBrowseForFolder Lib "shell32.dll" Alias _
            "SHBrowseForFolderA" (lpBrowseInfo As BROWSEINFO) _
            As Long
            
Private Const BIF_RETURNONLYFSDIRS = &H1
Public Function BrowseFolder(szDialogTitle As String) As String
  Dim X As Long, bi As BROWSEINFO, dwIList As Long
  Dim szPath As String, wPos As Integer
  
    With bi
        .hOwner = hWndAccessApp
        .lpszTitle = szDialogTitle
        .ulFlags = BIF_RETURNONLYFSDIRS
    End With
    
    dwIList = SHBrowseForFolder(bi)
    szPath = Space$(512)
    X = SHGetPathFromIDList(ByVal dwIList, ByVal szPath)
    
    If X Then
        wPos = InStr(szPath, Chr(0))
        BrowseFolder = Left$(szPath, wPos - 1)
    Else
        BrowseFolder = vbNullString
    End If
End Function
'*********** Code End *****************

How would i retreive the directory and store it in a text box?

Regards

Anthony
 

Users who are viewing this thread

Back
Top Bottom