Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Importing / Linking / August 2004

Tip: Looking for answers? Try searching our database.

Save Export  file location

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Raj - 27 Aug 2004 03:02 GMT
Is it possible to have a pop-up that lets the user select
where they would like to have the file saved? Also what
if you wanted it to save to the current machines desktop
as default?
Thanks.
DoCmd.TransferSpreadsheet acExport, 8, _
"MainData", "C:\Documents and Settings\DB1\Desktop", True
John Nurick - 27 Aug 2004 06:38 GMT
Hi Raj,

You can do this by using the code at
http://www.mvps.org/access/api/api0001.htm to display the standard
File|Save dialog.

ALternatively if you're using a recent version of Access you can use the
Application FileDialog object

>Is it possible to have a pop-up that lets the user select
>where they would like to have the file saved? Also what
[quoted text clipped - 3 lines]
>DoCmd.TransferSpreadsheet acExport, 8, _
>"MainData", "C:\Documents and Settings\DB1\Desktop", True

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Raj - 27 Aug 2004 16:34 GMT
John,
Can you help me out with adding the FileDialog in to my
code.  I looked it up in the HElp and tried to use the
exmaple but keep getting and error  'user defined type
not defined' error.
Thanks Raj

DoCmd.TransferSpreadsheet acExport, 8, _
"MainData", "C:\Documents and Settings\DB1\Desktop", True

>-----Original Message-----
>Hi Raj,
[quoted text clipped - 19 lines]
>Please respond in the newgroup and not by email.
>.
John Nurick - 27 Aug 2004 20:47 GMT
Raj,

I'm not going to guess. Please post the code you were using and indicate
the line at which the error occurs. Also, which versions of Access and
Windows are you using?

>John,
>Can you help me out with adding the FileDialog in to my
[quoted text clipped - 34 lines]
>>Please respond in the newgroup and not by email.
>>.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
Raj - 28 Aug 2004 04:55 GMT
John,
Here is the code.
Thanks

On Error GoTo Err_cmdExport_Click

   Dim stDocName As String
   Dim dlgSaveAs As FileDialog

Set dlgSaveAs = Application.FileDialog( _
   FileDialogType:=msoFileDialogSaveAs)

dlgSaveAs.Show
       
DoCmd.TransferSpreadsheet acExport, 8, _
"MasterData", "dlgsaveAs", True

Exit_cmdExport_Click:
   Exit Sub

Err_cmdExport_Click:
   MsgBox Err.Description
   Resume Exit_cmdExport_Click
   
End Sub
>-----Original Message-----
>Raj,
[quoted text clipped - 47 lines]
>Please respond in the newgroup and not by email.
>.
John Nurick - 28 Aug 2004 09:56 GMT
Raj,

As I understand it you want to let the user select a folder in which to
save the exported file, rather than specify a file name. For that you
need to use Application.FileDialog(msoFiledialogFolderPicker). In any
case, according to
http://support.microsoft.com/default.aspx?scid=kb;EN-US;282335 you
cannot use msoFileDialogSaveAs in Access 2002 (I don't know whether the
problem has been fixed in Access 2003). The other problem in your code
is that you didn't do anything to pass the selected name from the dialog
to TransferSpreadsheet. What you need is something like the code below.

Private Sub cmdExport_Click()

 Const FILENAME = "XXX.xls"
 Const INITIAL_FOLDER = "C:\Folder\Subfolder"
 Dim strFileName As String
 Dim dlgD As Office.FileDialog
 
On Error GoTo Err_cmdExport_Click
 
 Set dlgD = Application.FileDialog(msoFileDialogFolderPicker)
 With dlgD
   .Title = "Select location to save file"
   .InitialFileName = INITIAL_FOLDER
   .Show
   If .SelectedItems.Count = 0 Then
     MsgBox "User clicked Cancel", vbInformation + vbOKOnly
     GoTo Exit_cmdExport_Click:
   End If
   strFileName = .SelectedItems(1) & "\" & FILENAME
 End With
 MsgBox "About to save to " & strFileName, _
     vbInformation + vbOKOnly
 DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, _
     "MainData", strFileName, True
   
Exit_cmdExport_Click:
 Set dlgD = Nothing
 Exit Sub

Err_cmdExport_Click:
 MsgBox Err.Description
 Resume Exit_cmdExport_Click
End Sub


>John,
>Here is the code.
[quoted text clipped - 77 lines]
>>Please respond in the newgroup and not by email.
>>.

--
John Nurick [Microsoft Access MVP]

Please respond in the newgroup and not by email.
- 29 Aug 2004 03:52 GMT
John,
Thank you!!! I am just learning Coding and would have
never figured this out...
Thanks again
Raj
>-----Original Message-----
>Raj,
[quoted text clipped - 130 lines]
>Please respond in the newgroup and not by email.
>.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.