How to open workbooks in a different excel VBA -
i have method do folder(folder)
looping through sub folders , in method each file matches right criteria want edit workbook. when right folder error apear saying file doesn't exist. here code:
sub dofolder(folder) dim subfolder each subfolder in folder.subfolders dofolder subfolder next dim file each file in folder.files if file.type = "microsoft excel macro-enabled worksheet" dim wb workbook dim ws worksheet set wb = workbooks.open(filename:=file.path, readonly:=false, ignorereadonlyrecommended:=true, editable:=true) set ws = wb.worksheets(1) ws.range("a1").interior.colorindex = 1 wb.close savechanges:=true else end if next end sub
and here problem magnified:
set wb = workbooks.open(filename:=file.path, readonly:=false, ignorereadonlyrecommended:=true, editable:=true) set ws = wb.worksheets(1) ws.range("a1").interior.colorindex = 1 wb.close savechanges:=true
for whatever reason debugger shows wb
nothing , that's problem how fix it?
include additional window in toolbar , in debug mode, see name of file view\locals window
. may temporary (the ones open). name file starting ~$
. cuts temporary files, example:
if mid ([filename], 1, 2) <> "~$"
Comments
Post a Comment