+ Reply to Thread
Results 1 to 4 of 4

Need Additional Code To Automatically Import New XML Files From Folder

  1. #1
    Registered User
    Join Date
    05-04-2015
    Location
    Canada
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    4

    Need Additional Code To Automatically Import New XML Files From Folder

    Hello, everyone!

    This is my first post here and I'm hoping someone can help! I'm using code I found online to automatically populate an excel workbook from a folder of xml files. It adds each xml file in separately and organizes it into the proper rows and columns. The code works great for doing this but there's one thing I need it customized for. Every time it is run it adds EVERY file again. Is there a way to get it to automatically add new files, while ignoring ones it has already added? The XML files are online forms people are filling out so I will be saving new xml files regularly and would like them to automatically be added to the excel file when I open it. Here's the code I'm currently using:

    Please Login or Register  to view this content.
    I'm having trouble finding out how to do this online so I hope someone can help. Let me know if you need any additional details.

    Thanks!

  2. #2
    Registered User
    Join Date
    05-04-2015
    Location
    Canada
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    4

    Re: Need Additional Code To Automatically Import New XML Files From Folder

    I'm bumping this because I haven't been able to find a solution. Still hoping I can be helped. Would additional information on what I'm trying to accomplish help?

  3. #3
    Registered User
    Join Date
    05-04-2015
    Location
    Canada
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    4

    Re: Need Additional Code To Automatically Import New XML Files From Folder

    Bumping this one last time in desperation

  4. #4
    Registered User
    Join Date
    05-04-2015
    Location
    Canada
    MS-Off Ver
    Microsoft Excel 2010
    Posts
    4

    Re: Need Additional Code To Automatically Import New XML Files From Folder

    So I think I found a workaround for what I was trying to accomplish. I have attached the excel file for anyone else wishing to do something similar. I couldn't get help on these forums but I saw a lot of people online looking to automatically import xml files to Excel, so I'll explain everything I did and what I implemented as a solution to my problem. Hopefully someone will find it helpful in the future.

    Please Login or Register  to view this content.
    I don't know Visual Basic at all and I'm completely new to macros in general so I couldn't do specifically what I wanted. I found the code in my first post online and it did most of what I wanted it to do but it was missing a key function that I needed. It took XML files that were saved in a single folder and imported them into Excel, but each time I ran the macro it added every single folder item again. I wanted to add ONLY new ones that weren't in the workbook already. I worked around this by adding code that deleted everything on the sheet before it ran the XML to XL import code. Basically you're deleting everything and starting from scratch but you don't have to manually delete everything and then run the macro to get an updated list every time. Just press the button and it does its thing.

    That was a simple code found online:
    Please Login or Register  to view this content.
    This is a messy way of doing things, but it ends up giving me exactly what I want.

    I added one more thing, which was an autofit code (again simple, again found online) so that the columns would adjust according to the data.

    Please Login or Register  to view this content.
    I stuck both those extra pieces of code where I thought they should go logically. It seems to be working great. I then added a button to the workbook so that you could press it to run the macro.

    I have attached the workbook that has the macro in it, and the button off to the side on sheet1. To get it to work you'll have to throw some xml files in a folder, change the file path in the macro to that folder (where it indicates you make the change), and then press the button or run the macro in whatever way. I have an xml file on MediaFire I could share but I'll hold off on that unless someone requests it. I'm not sure what the rules are on Excel Forum for filesharing from a third party website.

    Anyways, thought I better share this information because I saw others asking about it online and you can never have too much knowledge. If anyone wishes to comment on a better method of doing this I encourage them to add to the discussion. If not, that's fine too!
    Attached Files Attached Files

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Need to retain text format in code to import all csv files in folder
    By rebubula in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 01-14-2014, 06:04 PM
  2. Noob 4 Help - Macro to LIST ALL FILES IN FOLDER and then IMPORT ALL LISTED FILES
    By StlSmiln in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 06-25-2012, 04:02 AM
  3. Replies: 1
    Last Post: 01-24-2006, 11:35 AM
  4. Replies: 1
    Last Post: 01-24-2006, 11:00 AM
  5. Replies: 1
    Last Post: 01-24-2006, 12:25 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1