Are d, w and m variables? If not then you need to put them in quotes. Setting Option Explicit will help you avoid these issues.