Results 1 to 7 of 7
  1. #1
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38

    DoCmd.RunSavedImportExport file name

    Hey guys,



    I am using DoCmd.RunSavedImportExport "ExportXML"

    to automatically export a file. But I want to be able to choose the name of this file.

    Any ideas?

    I don't really care how it's done, just need to do it. For example, a textbox on a form to specify the name of the file, or preferably a dialog box that pops up asking for the name.

  2. #2
    maximus's Avatar
    maximus is offline Expert
    Windows 7 Access 2010 (version 14.0)
    Join Date
    Aug 2009
    Location
    India
    Posts
    931
    Try this:
    Code attached to a command Button. when Clicked shoots up a input box which collects the file name:

    Dim strTypeFileName As String
    strFilename = InputBox("Please type file Name")
    DoCmd.RunSavedImportExport strFileName

    To use a text box say text1:

    Dim strTypeFileName As String
    strFilename = Me.text1
    DoCmd.RunSavedImportExport strFileName

  3. #3
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38
    This won't work because the argument thrown to RunSavedImportExport must be the Saved Export name, which is a fixed name for the saved export action, not a filename.

  4. #4
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38
    Quote Originally Posted by svcghost View Post
    This won't work because the argument thrown to RunSavedImportExport must be the Saved Export name, which is a fixed name for the saved export action, not a filename.
    anyone else have an idea?

  5. #5
    jasonbarnes is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Dec 2010
    Location
    NC
    Posts
    56
    Did you ever figure this out? I am going to have the problem very shortly. Hopefully the books I just ordered will give me the answer.

    I'm thinking we'll have to ditch the DoCmd.RunSavedImportExport
    and do the whole export from vba

    If I figure it out I'll let you know.

  6. #6
    svcghost is offline Advanced Beginner
    Windows XP Access 2007
    Join Date
    Sep 2010
    Posts
    38
    Nope. I decided to go a different route, which worked for me. But I never implemented a dialog box or other method of choosing a name for the file on the spot.. but I can't imagine it's too much more work given that you know this:

    Code:
    Private Sub ExportXMLData()
    Application.ExportXML _
    ObjectType:=acExportTable, _
    DataSource:="TableNameHere", _
    DataTarget:="FilePathHere"
     
    End Sub
    For the TableNameHere, use the table name (e.g. Customers)
    For the FilePathHere, use a file path INCLUDING the file name (e.g. C:\Exports\customer_export.xml) (or, C:\Exports\" & vFileName & ") vFileName would be your variable holding the file name.

    Now since you wanna choose the name of the file, I suggest using the variable approach in place of the customer_export.xml like above.. then use that variable to be received from what you type in a dialog box.

    Doest this help? Hope so.

  7. #7
    thhui is offline Competent Performer
    Windows XP Access 2002
    Join Date
    Feb 2009
    Posts
    235
    In order to use the file dialog,
    you have to insert code for windows api class to open the file dialog.

    See the following link for reference:-
    http://www.mvps.org/access/api/api0001.htm

Please reply to this thread with any new information or opinions.

Similar Threads

  1. RunSavedImportExport
    By rich in forum Import/Export Data
    Replies: 4
    Last Post: 03-14-2013, 02:54 PM
  2. my first DoCmd.RunSQL
    By broecher in forum Programming
    Replies: 4
    Last Post: 11-05-2010, 09:35 PM
  3. Replies: 1
    Last Post: 09-27-2010, 10:10 AM
  4. DoCmd.TransferText only if file is new
    By Coolpapabell in forum Programming
    Replies: 1
    Last Post: 10-14-2009, 01:57 AM
  5. DoCmd.SendObject Help
    By bgreer5050 in forum Programming
    Replies: 0
    Last Post: 01-12-2007, 06:27 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums