excel - Convert all files from .html to .xlsx in a folder and save as filename using VBA -
my problem header states.
convert files within folder html (downloaded browser) .xlsx format.
- i use same folder path store files want converted , supersede on daily basis
- the number of files used on daily basis change
- there no 'file masks' relevant files ones within folder, there no subfolders
- files must opened, converted xlsx , saved again same name of source file.
- rinse , repeat until files have been converted , saved within same (or different if easier folder)
- i using excel 2011 (for mac) therefore file paths little different, if vba code, there should no issues of using on platform. main difference paths separated
:
instead of\
. e.g.macintosh hd:users:documents:r7m:planning:locations
some of links have researched come close answer here:
opens txt files , saves excel : tried changing of information
looping through files in folder mac : advanced, reference need used. wasn't allowed post 3 links site gives references... think.
this (from link 1) may closest thing need...
private sub commandbutton1_click() dim myfolder string dim myfile string dim foldername string application.filedialog(msofiledialogfolderpicker) .allowmultiselect = false if .show = -1 foldername = .selecteditems(1) end if end myfile = dir(foldername & "\*.txt") while myfile <> "" workbooks.opentext filename:=foldername & "\" & myfile 'save excel file activeworkbook.saveas filename:=foldername & "\" & replace(myfile, ".txt", ".xls") 'use below 3 lines if want close workbook right after saving, dont have lots of workbooks opened application.displayalerts = false activeworkbook.close application.displayalerts = true myfile = dir loop end sub
any great!
Comments
Post a Comment