-
A couple more comments as I glance over your project:
1. Look up the concept of "Scope" as it pertains to variables. You need to understand the difference between a global (or public) variable (available for use with all sub-routines in your project), a module-level variable (available to all sub-routines in your project) and a subroutine variable (only available within that routine). You also need to understand when those variables fall out of "scope" (i.e., when they automatically empty themselves out and/or release the memory they would use).
A lack of understanding on this concept is going to cause you troubleshooting/debugging headaches later. For now, don't "Dim" any variables anywhere but inside a specific routine. So putting "Dim oCC As ContentControl" below Option Explicit but outside any subroutine is a "no no" until you fully understand what's happening there. Trust me on this.
And then when you do decide to apply this concept (global and module variables-- there are appropriate times to use it), give an appropriate prefix (in addition to you variable type prefix). So a global string variable might be
Public pub_sMyGlobalVariable as String
A module variable might be
Dim m_sMyModuleVariable As String
And your subroutine variable would be
Dim sMyVariable As String
2. Very rarely do you want the same routines automatically running in both a Document_New event and a Document_Open event. This will cause you headaches. As the template developer, just leave that code in the Document_New event (for anyone who creates a document based on the template, and leave Document_Open out of it. You can always manually run the Document_New event (with your cursor in the Document_New event and your newly discovered F8 command--or even F5).
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules