Quantcast
Viewing all articles
Browse latest Browse all 50123

how do I end this loop?

This loop returns "method open of object workbooks failed" when it should end:
Code:

StrPath = "C:\Documents and Settings\" & Environ("username") & "\Desktop\field reports\"
  StrFile = Dir(StrPath & SubgCode & "*" & ".xlsm")
    Do While Len(StrFile) > 0
'here's where it gets stuck after the directory runs out of files beginning with the specified string (as defined by "Subgcode"):
  Workbooks.Open StrPath & StrFile

Any suggestions?

Thanks,

willardio

Viewing all articles
Browse latest Browse all 50123

Trending Articles