Quote:
Originally Posted by Guessed
When the code fails, what is the value of StrWkBkNm?
StrWkBkNm = ThisDocument.Path & "\dados.xlsx"
ThisDocument.Path would fail in two potential ways:
- Document hasn't been saved therefore it has no path
- Code is in a template and not in the document itself.
|
In the first case, I expect the code would exit via:
Code:
If Dir(StrWkBkNm) = "" Then
MsgBox "Cannot find the designated workbook: " & StrWkBkNm, vbExclamation
Exit Sub
End If
without trying to open the workbook. In the second case, it would do likewise unless the workbook was in the same folder as the template.