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.
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:
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.
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!
Bookmarks