View Single Post
 
Old 07-25-2018, 04:12 AM
macropod's Avatar
macropod macropod is offline Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,963
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by Guessed View Post
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.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote