vbscript - VB Script to Refresh Excel -


i'm trying piece / learn vb create real simple script open excel document, based on file path specify, refresh external data connections. wait until refresh done, save file in same location, quit excel.

what have far, seems work other when saves file, saves different location, , not overwrite existing file!

this first use of vb, booked go on course in few months time, wanted experiment bit first, grabbing bit of code google , site :)

sorry if easy question, me quite challenging!!

here's have far....

dim oexcel set oexcel = createobject("excel.application")   oexcel.visible = true oexcel.displayalerts = false oexcel.asktoupdatelinks = false oexcel.alertbeforeoverwriting = false  set oworkbook = oexcel.workbooks.open("the file path of .xlsx file") oworkbook.refreshall oworkbook.save  oexcel.quit set oworkbook = nothing set oexcel = nothing 

what want happen is, open excel file location named, update external data, save file, overwriting original. close excel.

thanks ever john.

try below

oworkbook.refreshall 'refresh doevents 'let excel finish oworkbook.close true 'close workbook true save. 

Comments

Popular posts from this blog

javascript - Google App Script ContentService downloadAsFile not working -

javascript - Function overwritting -

c# - Exception when attempting to modify Dictionary -