I want to copy data from multiple .xml to a current excel -


i have problem, new vba programming , in dilema.

i have folder 20-50 xml files containing test results. want create macro select folder, open each .xml file , copy specific value(s). example in column z have @namerecord , in column aa have data itself. each .xml file has 1 or more data , want copy each data each xml new column in base workbook. want first column have name of file succeded in doing.

for record each .xml file when open have choose "open file without applying stylesheet" "ok" press , after have select "as read-only workbook" , press "ok".

my code far looks got error 438 "object doesn't support property or method" , shows present

" selection.pastespecial paste:=xlpasteall, operation:=xlnone, skipblanks:=true, transpose:=true"

i have word 2003.

hope can , thank in advance.

function lastrow(sh worksheet)     on error resume next     lastrow = sh.cells.find(what:="*", _                             after:=sh.range("a1"), _                             lookat:=xlpart, _                             lookin:=xlvalues, _                             searchorder:=xlbyrows, _                             searchdirection:=xlprevious, _                             matchcase:=false).row     on error goto 0 end function  sub filenames()  sheet2.cells.clearcontents  dim strfolder string, ws worksheet, strfile string, r range, my_range range application.filedialog(msofiledialogfolderpicker) .allowmultiselect = false .initialfilename = application.defaultfilepath if .show = -1 _ strfolder = .selecteditems(1) end  if strfolder = "" msgbox "no folder selected! exiting sub...": exit sub      folderpath = application.defaultfilepath      set ws = sheets("rawdata")      ws.range("a1") = array("filename")     strfile = dir(strfolder & "\*.xml")     if strfile <> ""                 set r = ws.cells(rows.count, "a").end(xlup).offset(1)         r.value = strfile: r.offset(0).value = strfile         strfile = dir         loop until strfile = "" end if    while filename <> ""       application.screenupdating = false         set wb = workbooks.open(folderpath & filename)          filename = dir     loop   application.screenupdating = true  end sub  'copiaza  sub @nameuri()      dim wrkbook workbook     dim strfilename string     dim filelocnstr string     dim rowcounter integer      filelocnstr = curdir() 'thisworkbook.path      dim strfile string     strfile = dir(filelocnstr & "\*.xml")      rowcounter = 2     while len(strfile) > 0     call operations(filelocnstr & "\" & strfile, rowcounter)     strfile = dir     rowcounter = rowcounter + 1  loop  sheets(1).select msgbox "action complete"  end sub  private sub operations(strfilename string, rowcounter integer)      workbooks.open (strfilename)      call edit(rowcounter)      workbooks.open (strfilename)      activeworkbook.close  end sub  sub edit(rowcounter integer) dim lngcalc integer  dim wb1 workbook dim ws1 worksheet dim loopcal long   application     .screenupdating = true     .enableevents = true     lngcalc = .calculation  end       rows("2:2").select     selection.autofilter   if range("z2") = "/function/devices/device/@name/extendeddata/data/@name"      range("x4").select     activesheet.range("$a$2:$ew$2197").autofilter field:=26, criteria1:= _         "@namerecord"       set wb1 = activeworkbook     sheets(1).select     range("aa3:aa3000").select     selection.copy elseif range("aa2") = "/function/devices/device/@name/extendeddata/data/@name"      range("x4").select     activesheet.range("$a$2:$ew$2197").autofilter field:=27, criteria1:= _         "@namerecord"       set wb1 = activeworkbook     sheets(1).select     range("ab3:ab3000").select     selection.copy end if       windows(2).activate     sheets(2).select     range("b" & rowcounter).select  'index variable ensure cell reference changes each time.     selection.pastespecial paste:=xlpasteall, operation:=xlnone, skipblanks:=true, transpose:=true     selection.pastespecial paste:=xlpastevalues, operation:=xlnone, skipblanks:=true, transpose:=true  application.displayalerts = false  end sub 


Comments

Popular posts from this blog

php - Submit Form Data without Reloading page -

linux - Rails running on virtual machine in Windows -