Hello twyblue,
Welcome to the Forum!
You have created the Word document from inside Excel at run time. A method known as "late binding". One drawback to this method is named constants, like wdExportFormatPDF, are not available at run time. You must either define this constant in your code or use its numeric value. In the code below, I defined the constant. For me, it maintains consistency with the object model and is more easily understood.
Simply put, Binding is the act of associating objects with their defined names in memory during compile time. With early binding, the compiler can tell the CPU to jump directly to the object’s address. With late binding, the program has to read the address held in the object's pointer and then jump to that address. This involves one extra step, making it slightly slower. However, the advantage of late binding is that it is more flexible than early binding. Because decisions about which functions to call, like which version to use, do not need to be made until run time.
Bookmarks