Excel gets stuck when running VBA macro -


i started getting problem when clicking custom ribbon shortcut (which runs few macros)

the code involves opening, saving, closing, deleting workbooks, downloading , parsing xml data through api, , copying , copying other workbooks

description:  problem caused program stop interacting windows.   problem signature:   problem event name:    apphangb1   application name:    excel.exe   application version:    15.0.4420.1017   application timestamp:    506741b5   hang signature:    6acb   hang type:    0   os version:    6.1.7601.2.1.0.256.1   locale id:    1037   additional hang signature 1:    6acb5e8afc59fd5d0f16b73953ad555b   additional hang signature 2:    94d6   additional hang signature 3:    94d63882b3db19ba84c338ce0a96f1fe   additional hang signature 4:    6acb   additional hang signature 5:    6acb5e8afc59fd5d0f16b73953ad555b   additional hang signature 6:    94d6   additional hang signature 7:    94d63882b3db19ba84c338ce0a96f1fe   read our privacy statement online:   http://go.microsoft.com/fwlink/?linkid=104288&clcid=0x0409   if online privacy statement not available, please read our privacy statement offline:   c:\windows\system32\en-us\erofflps.txt 

the error above happens every time open workbook , run code first time after windows launch. causes excel crash, reopen workbook, rerun code , error doesn't happen anymore. happen next time restart pc, , on.

i started getting these errors during past week after made improvements in code , added more macros (all run clicking custom ribbon button)

problem signature:  problem event name:    appcrash   application name:    excel.exe   application version:    15.0.4420.1017   application timestamp:    506741b5   fault module name:    vbe7.dll   fault module version:    7.1.10.38   fault module timestamp:    4fea3eec   exception code:    c0000005   exception offset:    00000000000412fc   os version:    6.1.7601.2.1.0.256.1   locale id:    1037   additional information problem:   lcid:    1033   skulcid:    1037 

the error above happened few days ago, reason don't error anymore thinking might tell problem lies?

i started getting problem during past week after made improvements in code , added more macros (all run clicking custom ribbon button)

what possibly wrong code or has excel settings? or how know line in code triggers error?

edit:

here vba code requested

clicking button in quick access toolbar triggers following sub:

sub importtosales()  application.screenupdating = false  workbooks.open ("e:\ebay.xlsb")  application.run "ebay.xlsb!getorders" application.run "ebay.xlsb!copytosales"  application.screenupdating = true application.displayalerts = false  end sub 

getorders: (download , parse new orders data through api)

sub getorders()      sheets("copy").activate      application.displayalerts = false      on error goto errhandle       dim body string: body = "..."       set objhttp = createobject("winhttp.winhttprequest.5.1")      url = "" 'api url      objhttp.open "post", url, false      objhttp.setrequestheader "" 'request headers       objhttp.send (body)       set objxml = new msxml2.domdocument      objxml.async = false      objxml.loadxml (convertfromutf8(objhttp.responsetext)) 'calls function convert encoding       set objxsl = new msxml2.domdocument      objxsl.async = false      objxsl.load "e:\removeaccent.xsl" 'changes accented chars regular chars       ' transforming objxml newxml      set newxml = new msxml2.domdocument      objxml.transformnodetoobject objxsl, newxml       ' notice newxml references      xmlnamespaces = "xmlns:doc='urn:ebay:apis:eblbasecomponents'"      newxml.setproperty "selectionnamespaces", xmlnamespaces      newxml.setproperty "selectionlanguage", "xpath"       dim xitemlist ixmldomnodelist      set xitemlist = newxml.documentelement.selectnodes("//doc:transaction")       dim xitem ixmldomnode      dim copy worksheet      set copy = worksheets("copy")       application.displayalerts = false       dim salesws worksheet      dim saleslr integer       set salesws = workbooks("sales.xlsm").worksheets("sales")      saleslr = workbooks("sales.xlsm").worksheets("sales").cells(rows.count, "b").end(xlup).row       row = 1       each xitem in xitemlist          'calls function check if order exists in master sheet; if not proceed          if checkexist(xitem.selectsinglenode("descendant::doc:transactionid").text, salesws, saleslr) = false          copy.cells(row, 1) = xitem.selectsinglenode("ancestor::doc:order/descendant::doc:buyeruserid").text          copy.cells(row, 2) = xitem.selectsinglenode("ancestor::doc:order/descendant::doc:shippingaddress/doc:name").text          row = row + 1          end if      next       'if no new orders end operation      if row = 1      workbooks("sales.xlsm").activate      msgbox "there no new orders import.", vbinformation      thisworkbook.close      end if       set objhttp = nothing      set objxml = nothing       'sort rows order date      columns("a:ao").select         selection.sort key1:=range("y2"), order1:=xlascending, header:=xlguess, _     ordercustom:=1, matchcase:=false, orientation:=xltoptobottom, _     dataoption1:=xlsortnormal      sheets("paste").activate     prtousa 'replace "puerto rico" "usa"      exit sub  errhandle:         ' missing node error         if err.number = 91             resume next         ' other errors         else:             msgbox err.number & " - " & err.description, vbcritical, "runtime error"             exit sub         end if   end sub 

copytosales: (copy downloaded , converted data master sheet)

sub copytosales() application.enablecancelkey = xldisabled application.screenupdating = false  dim sales workbook dim orders workbook dim salessh worksheet dim orderssh worksheet dim ebay workbook dim copy worksheet dim paste worksheet  workbooks.open ("e:\orders.xlsx")  set sales = workbooks("sales.xlsm") set salessh = sales.worksheets("sales")  set orders = workbooks("orders.xlsx") set orderssh = orders.worksheets("orders")  set ebay = workbooks("ebay.xlsb") set copy = ebay.worksheets("copy") set paste = ebay.worksheets("paste")  dim datalr long dim saleslr long dim orderslr long  'set last rows datalr = copy.range("a" & rows.count).end(xlup).row + 2 saleslr = salessh.range("a" & rows.count).end(xlup).row + 1 orderslr = orderssh.range("a" & rows.count).end(xlup).row + 1  'copy data master sheet  paste.rows("3:" & datalr).copy salessh.range("a" & saleslr).pastespecial xlpastevalues, skipblanks:=true  'generate product pictures next order number salessh.activate application.run "sales.xlsm!generatepictures"  sendkeys ("{esc}") salessh.range("a1").select application.cutcopymode = false  'generate order numbers dim long dim j long dim lastorder integer dim multi boolean  saleslr = salessh.range("b" & rows.count).end(xlup).row lastorder = split(range("b" & saleslr).value, "-")(0)  j = 1 = saleslr + 1  while not isempty(activesheet.range("h" & i))     if activesheet.range("h" & i) = activesheet.range("h" & + 1)      multi = true      while multi = true     activesheet.range("b" & i) = lastorder + 1 & "-" & j     j = j + 1     if activesheet.range("h" & i) = activesheet.range("h" & + 1)     multi = true     = + 1     else     multi = false     end if     wend      lastorder = lastorder + 1     j = 1     else      activesheet.range("b" & i) = lastorder + 1     lastorder = lastorder + 1     end if      application.cutcopymode = false     = + 1 wend  'copy data secondary sheet  orderssh.activate orderssh.range("a1").select application.cutcopymode = false saleslr = saleslr + 1  salessh.range("a" & saleslr & ":" & "s" & datalr + saleslr - 3).specialcells(xlcelltypevisible).copy  orderssh.range("a" & orderslr).select orderssh.paste  'copy prices secondary sheet master sheet  salessh.range("u" & saleslr & ":" & "u" & saleslr + datalr - 3).copy  orderssh.range("q" & orderslr).pastespecial xlpastevalues salessh.range("u" & saleslr & ":" & "u" & saleslr + datalr - 3).clearcontents  'select last row in secondary sheet sendkeys ("{esc}") orderssh.range("b" & orderslr + datalr - 3).select  'scroll first row of new data in secondary sheet activewindow.scrollrow = selection.row - datalr + 3 activewindow.scrollcolumn = selection.column  'select last row in master sheet salessh.activate sendkeys ("{esc}") salessh.range("b" & saleslr + datalr - 3).select  'scroll first row of new data in master sheet salessh.activate activewindow.scrollrow = selection.row - datalr + 3 activewindow.scrollcolumn = selection.column  application.displayalerts = true application.screenupdating = false application.run "sales.xlsm!uploadpic" 'copies product pictures of new orders master drive backup drive ebay.saved = true ebay.close  end sub 


Comments

Popular posts from this blog

angular - Is it possible to get native element for formControl? -

unity3d - Rotate an object to face an opposite direction -

javascript - Why jQuery Select box change event is now working? -