The most important thing to remember when writing an add-in is the definition of the active workbook. The active workbook is the one that's on top in the Microsoft Excel window. The active workbook isn't necessarily the one that contains the running Visual Basic code. In fact, an add-in can never be the active workbook, because it's invisible.
When you're writing and debugging an add-in, the workbook that contains the code is often the active workbook. Therefore, statements that contain an implicit ActiveWorkbook property call — such as DialogSheets("MyDialog").Show — work properly. When you compile the add-in and run the same code, the implicit ActiveWorkbook property call returns the workbook that's on top, not the workbook that contains the dialog sheet named "MyDialog." This causes the code to fail.
Using the ThisWorkbook property eliminates the workbook referencing problem. In addition to using ThisWorkbook, you should always use complete references to objects, meaning that you should start with ThisWorkbook and then navigate down the object hierarchy, as shown in the following code.
Don't forget that objects are often used in arguments to methods; it's very easy to overlook the workbook reference issue in such cases, as shown in the following code.