excel - How to open file using Open File Dialog -
i've been searching on web solution on how open file using open file dialog in vbscript. can point me on right track?
my code below opens excel file wanted more dynamic in terms input file name can change , not hard coded.
set objexcel = createobject("excel.application") objexcel.displayalerts = 0 set objshell = wscript.createobject("wscript.shell") path = objshell.currentdirectory infilename = "inputfile.xlsx" infilepath = path + "\" + infilename 'open target workbook set objworkbook1 = objexcel.workbooks.open(infilepath, false, true) msgbox "reading data " & infilename & vbnewline, vbokonly + vbinformation, _ "reading data"
when in doubt, read documentation.
set dialog = objexcel.filedialog(3) dialog.allowmultiselect = true dialog.show each f in dialog.selecteditems set objworkbook = objexcel.workbooks.open(f) '... stuff ... objworkbook.close next
Comments
Post a Comment