Results 1 to 6 of 6
  1. #1
    dh010010 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    4

    Have access rename a .txt file and move it

    Afternoon!

    I currently have a database that creates a .txt file which contains information from one of my tables.



    I need access, after it has written the file, to rename if from a .txt file to a .xml

    I have already looked at exporting as an .xml but the xml file does not come out right and only work as I am doing presently.

    Is there any way I can get access to change the .txt to .xml?

    Any help would be great.

  2. #2
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    You can use Name to rename a file like this:
    Path = Filepath
    If Dir(Path & Name.txt, vbDirectory) <> "" Then
    Name Path &Name.txt As Path & Name.xml
    end if

  3. #3
    dh010010 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    4
    thanks for that it worked a treat!

    Just have one more question /

    Is there any way i can use %userprofile% in the code.

    The problem is that i need the file to rename and move to another location however the location is different for each user (because of there user name).

    Any ideas how I would get round this?

  4. #4
    SoftwareMatters is offline Access VBA Developers
    Windows XP Access 2003
    Join Date
    Mar 2009
    Location
    Dorset
    Posts
    274
    I saw this the other day that might be useful but have not tested it.
    http://www.ehow.com/how_4753053_vba-...-username.html

  5. #5
    dh010010 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    4
    Thanks for the quick reply.

    Unfortunatly I can already do what the link is showing, which is to get the user name.

    How do i explain this.......

    I want to be able to save the file to:

    %userprofile%\application data\idonk\data\MYFILE.xml

    the %userprofile% bit is not understood by access when saving a file it wants be to put

    c:\documents and settings\myusername\application data\idonk\data\MYFILE.xml

    but "myusername" will change with each user.

    The %userprofile% (if you type it in run) auto takes you to the current users files.

    Any further ideas..... sorry if this does not make sense or i repeat myself, its been a long day!

  6. #6
    dh010010 is offline Novice
    Windows XP Access 2007
    Join Date
    Jul 2010
    Posts
    4
    I DONE IT!


    Just so you know....

    the save location was like so.....

    "C:\Documents and Settings\" & Environ("username") & "\application data\{FAB3AFF7-DA5E-431E-B81A-D94492775BCB}UpdateData.xml"

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

Similar Threads

  1. Move to next field command...
    By mvolpone in forum Forms
    Replies: 1
    Last Post: 07-06-2010, 09:30 PM
  2. Replies: 1
    Last Post: 05-13-2010, 10:37 AM
  3. docmd.rename wierd results
    By hyperionfall in forum Programming
    Replies: 1
    Last Post: 03-04-2010, 01:18 PM
  4. Move data from one table to another
    By rebyrd in forum Queries
    Replies: 2
    Last Post: 12-24-2009, 12:52 AM
  5. Transfer SpreadSheet Command and Rename
    By fintan06 in forum Import/Export Data
    Replies: 2
    Last Post: 10-15-2009, 08:00 AM

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