excel vba - VBA Code to set the file path dynamically -


i have vba code read xml below

 strtargetfile = "c:\users\xxxxxx\desktop\xxxxxx\xxxx\xml\details.xml"  set wb = workbooks.openxml(filename:=strtargetfile, loadoption:=xlxmlloadimporttolist) 

is there way remove hardcoding ??

if have xml folder in same folder workbook folder try this:

sparentfolder = left(thisworkbook.path, instrrev(thisworkbook.path, "\") - 1) strtargetfile = sparentfolder & "\xml\details.xml" set wb =   workbooks.openxml(filename:=strtargetfile,loadoption:=xlxmlloadimporttolist) 

Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -