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):
Sub Makro2()
With ActiveSheet.QueryTables.Add(Connection:= _
"FINDER;C:\Users\vem\Desktop\Fältformulär test\Ifyllt\2012-11-19.xml", _
Destination:=Range("$A$2"))
.Name = "2012-11-19_y"
.FieldNames = True
.RowNumbers = False
.FillAdjacentFormulas = False
.PreserveFormatting = True
.RefreshOnFileOpen = False
.BackgroundQuery = True
.RefreshStyle = xlOverwriteCells
.SavePassword = False
.SaveData = True
.AdjustColumnWidth = True
.RefreshPeriod = 0
.WebSelectionType = xlAllTables
.WebFormatting = xlWebFormattingNone
.WebPreFormattedTextToColumns = True
.WebConsecutiveDelimitersAsOne = True
.WebSingleBlockTextImport = False
.WebDisableDateRecognition = False
.WebDisableRedirections = False
.Refresh BackgroundQuery:=False
End With
End Sub
Is there anyone that can help me to get an open file dialog box in there?
Thanks in advance!
Victor
Bookmarks