vba - Macro to open a excel in shared path -
hi able open excel files in desktop. not able open excel in shared path. file not found error message displayed need help...!!! path starts 2 backslashes "\..\.....\"
sub open_hari() dim r long r = 1 10 if cells(r, 1).value <> "" workbooks.open filename:=sheet1.cells(r, 1).value end if next r end sub
i had no problem opening file of form \\myshare\etc\file.xlsx
vba. tried running code, , worked me point found non-empty cell... once found file , opened it, code automatically started looking @ cells in new workbook (i had file name in row 6; file opened, , code looked @ row 7 in newly opened file. did not have valid file name in it).
if cause of problem, solution set range before start scrolling through it... :
sub open_hari() dim mycells dim c set mycells = range(sheet1.[a1], sheet1.[a10]).cells each c in mycells if c.value <> "" workbooks.open filename:=c.value end if next c end sub
this solved problem me...
incidentally, add line
on error resume next
just before
workbooks.open
statement. way, if cell contains non-valid file name (but isn't empty), code keep right on going. doesn't figure out have problem code, it's idea not until it's thoroughly debugged. problem of looking @ different sheet invisible if you'd had error trap enabled.
Comments
Post a Comment