Modifying a closed excel sheet with VBA -
i trying open 1 spredsheet isn't in view. change column format of 1 of columns date using texttocolumns feature. changes should saved , file closed automatically.
when run following says no data selected parse. thoughts?
sub test() dim xlapp new excel.application dim xlwb excel.workbook dim xlws excel.worksheet xlapp.visible = false set xlwb = xlapp.workbooks.open("directory of file") set xlws = xlwb.worksheets("sheet 1") xlws.unprotect xlws.columns("f:f").select selection.texttocolumns destination:=range("f1"), datatype:=xldelimited, _ textqualifier:=xldoublequote, consecutivedelimiter:=false, tab:=true, _ semicolon:=false, comma:=false, space:=false, other:=false, fieldinfo _ :=array(1, 4), trailingminusnumbers:=true set xlws = nothing xlapp.displayalerts = false xlwb.close true set xlwb = nothing xlapp.quit set xlapp = nothing end sub
a bit of research should have given result, provide anyway...
'since want workbook invisible, have open in new excel application dim xlapp new excel.application dim xlwb excel.workbook dim xlws excel.worksheet xlapp.visible = false 'open workbook specified path set xlwb = xlapp.workbooks.open("your filepath here") 'select worksheet opened workbook set xlws = xlwb.worksheets("your worksheet name here") 'do 'example xlws.name = "asdf" 'cleanup set xlws = nothing xlwb.close 'true save changes, false discard changes set xlwb = nothing xlapp.quit set xlapp = nothing
Comments
Post a Comment