vbscript - How do you rename a file URL to a variable in VB script? -
i'm making program in microsoft excel using bunch of vb script macros. 1 of macros gets data "from web" , retrieves table sheet in excel. when "from web", copied , pasted url html file have on desktop. location of program going change frequently, need able have cell in excel can specify url, macro reference.
here code below:
sub importswipedatawithtitlesbeta() ' ' importswipedatawithtitlesbeta macro ' ' keyboard shortcut: ctrl+shift+k ' sheets("import swipe data").select cells.select selection.delete shift:=xlup range("a3").select activesheet.querytables.add(connection:= _ "url;file:///c:/users/sean/desktop/attendance program adc/acs%20onsite%20se%20complete.htm", _ destination:=range("$a$3:$c$3")) .name = "acs%20onsite%20se%20complete_8" .fieldnames = true .rownumbers = false .filladjacentformulas = false .preserveformatting = true .refreshonfileopen = false .backgroundquery = true .refreshstyle = xlinsertdeletecells .savepassword = false .savedata = true .adjustcolumnwidth = true .refreshperiod = 0 .webselectiontype = xlentirepage .webformatting = xlwebformattingnone .webpreformattedtexttocolumns = true .webconsecutivedelimitersasone = true .websingleblocktextimport = false .webdisabledaterecognition = false .webdisableredirections = false .refresh backgroundquery:=false end sheets("resource sheet").select range("b2:c2").select selection.copy sheets("import swipe data").select range("a1:b1").select activesheet.paste range("a2").select end sub
thanks help!
you don't need .select
every range use. these statements generated recording macro can clean code afterwards described here.
yet, answer question, can store url in var:
dim myurl string myurl = "url;" & sheets("import swipe data").range("a1").value activesheet.querytables.add(connection:= myurl, destination:=range("$a$3:$c$3")) (...) end
regards,
Comments
Post a Comment