+ Reply to Thread
Results 1 to 4 of 4

Import xml data by letting the user choose from file dialog box

  1. #1
    Registered User
    Join Date
    12-08-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2003
    Posts
    5

    Import xml data by letting the user choose from file dialog box

    Hey everyone,

    Hey!

    I'm new here and obviously I'm not a pro on VBA and macros. Been trying to solve my problems back and forth for weeks now and figured it´s about time to ask someone about it!

    Basically, I want to import an xml file into a certain cell on a worksheet in Excel.
    This can be done by just going on Data/From other sources/from xml data import.
    After choosing xml-file, I want the data to be placed into the worksheet, but not as a table, which is why I'm clicking on the second option in the window. I also choose an option in the properties window to overwrite.
    I want this action to be made just by clicking a button, which is going to happen with a macro.

    So, I tried to record a macro. It works fine, but I want a file dialog box to open for the user to choose a file instead of always having the same URL!
    I have also tried to make the same action from scratch with VBA, but it doesn't work. And I don't want to import the xml as a table, as that only pushes the existing data down, which is not preferred.

    The following is what I get with the recorded macro (pardon the Swedish):

    Please Login or Register  to view this content.
    Is there anyone that can help me to get an open file dialog box in there?

    Thanks in advance!
    Victor

  2. #2
    Forum Moderator Leith Ross's Avatar
    Join Date
    01-15-2005
    Location
    San Francisco, Ca
    MS-Off Ver
    2000, 2003, & 2010
    Posts
    23,258

    Re: Import xml data by letting the user choose from file dialog box

    Hello Victor,

    Welcome to the Forum!

    Can you post an example of how the data should appear on the worksheet?
    Sincerely,
    Leith Ross

    Remember To Do the Following....

    1. Use code tags. Place [CODE] before the first line of code and [/CODE] after the last line of code.
    2. Thank those who have helped you by clicking the Star below the post.
    3. Please mark your post [SOLVED] if it has been answered satisfactorily.


    Old Scottish Proverb...
    Luathaid gu deanamh maille! (Rushing causes delays!)

  3. #3
    Registered User
    Join Date
    12-08-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Import xml data by letting the user choose from file dialog box

    Hello Leith,

    Thankful for the quick answer.
    Unfortunately, I have the most up-to-date file on my computer at work but I managed to find an older file on my mail.
    Hope the picture helps you understand.

    In this case, I want the data to be inserted in cell A2.
    The reason why I want that is because another worksheet refers to all these different cells in order to complete a form.
    The problem when I insert xml as a table is that it just pushes the existing data down (even though I choose overwrite), which makes the reference actions from the other worksheet useless. Obviously the picture below shows an the inserted xml-data as a table, which is not the plan. Maybe you have a tip on how to deal with this?

    /Victor


    Example excel.jpg

  4. #4
    Registered User
    Join Date
    12-08-2012
    Location
    Sverige
    MS-Off Ver
    Excel 2003
    Posts
    5

    Re: Import xml data by letting the user choose from file dialog box

    Hi Leith,

    I understand if you cannot answer in these times of holidays and such. But is there any more I should provide you or others with?

    Sincerely
    Victor

+ Reply to Thread

Thread Information

Users Browsing this Thread

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

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