Consulting

Results 1 to 16 of 16

Thread: Open, Edit / Copy From 3 Separate Existing Macro Templates From Single Macro Template

  1. #1
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location

    Open, Edit / Copy From 3 Separate Existing Macro Templates From Single Macro Template

    I would like to be able to open a single instance of word where it is possible to select and open any of three existing macro enabled templates by the selection of a ribbon button.

    Each of the three will also have an option of either copying their content of their respective template to the clipboard or instigate the “Save As” prompt.

    I was wondering if this is at all possible and whether opening this instance of word could happen without having the default blank document showing?

    Each of any of the three opened documents should be able to be selected and re-edited if required without the need to open another instance of the template.

    I have attached what I hope is at least a step in the right direction. Any help would be very much appreciated.
    Attached Files Attached Files

  2. #2
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    I suspect you need to understand more about how Word and templates work.

    Why three macro-enabled templates?
    You could have QAT icons to create new documents based on non-macro-enabled or macro-enabled templates (rather than copy and paste). The icons would be linked to macros that create the documents, but those are trivial.
    You may very well be able to store the content you want in building blocks rather than separate templates and could simply have a building blocks gallery content control in one template. That would require no macros at all.
    - Templates in Microsoft Word
    - Automated Boilerplate Using Microsoft Word
    - Building Blocks Gallery Content Control

  3. #3
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location
    Thank you for your comments Chas.

    I have three existing macro-enabled templates because each does a very specific and different document to the others. The copy command is used solely to grab the contents of the document ready to be pasted into a third party bespoke data management system.

    I just thought it would be far simpler to be able to open one instance of word, then select one of the three documents that are required at any time, rather than the user clicking into a separate document for each occasion, potentially having up to three instances of word open. As highlighted in my original post, the same button should hopefully enable the user to go back and edit as some of the content control data may be the same, thus alleviating the need to re enter it every time. Each of the templates is able to do this already.

  4. #4
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Quote Originally Posted by HTSCF Fareha View Post
    I just thought it would be far simpler to be able to open one instance of word, then select one of the three documents that are required at any time, rather than the user clicking into a separate document for each occasion, potentially having up to three instances of word open.
    Isn't this exactly what Chas was talking about with building blocks? One instance of word is open, and you simply insert the building block (template) of your choice as and when required?
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  5. #5
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location
    Building blocks is a new one on me and I had not heard of them before Chas' reply.

    Am I understanding correctly that one could set up each of the templates as a building block? If this is not the case then I cannot see that this would help me (and therefore my work colleagues). Each of the existing templates contains text boxes, combo boxes, drop down lists etc. each of which would contain unique entries.

  6. #6
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Quote Originally Posted by HTSCF Fareha View Post
    Building blocks is a new one on me and I had not heard of them before Chas' reply.

    Am I understanding correctly that one could set up each of the templates as a building block? If this is not the case then I cannot see that this would help me (and therefore my work colleagues). Each of the existing templates contains text boxes, combo boxes, drop down lists etc. each of which would contain unique entries.
    If you are using "template" in the English language meaning - a pattern, yes.
    If the Word jargon meaning, no.
    Building blocks can hold tables, fields, content controls, pages and page breaks. They cannot hold a Word template.
    Take a look at what native Word features can do before trying to invent solutions that may already exist.

  7. #7
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location
    From what you are saying I'm guessing that the answer to my question in my original post is that this is not possible.

    It just seems strange to me that one can use a ribbon button to go back and edit the contents of a userform where the various inputs have been assigned to variables, but not to do the same by selecting a specific template.

    I may just have to contiune to use the three templates under separate instances of word.

    If the above is true then I am happy to resolve the thread as solved.

  8. #8
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Quote Originally Posted by HTSCF Fareha View Post
    From what you are saying I'm guessing that the answer to my question in my original post is that this is not possible.

    It just seems strange to me that one can use a ribbon button to go back and edit the contents of a userform where the various inputs have been assigned to variables, but not to do the same by selecting a specific template.

    I may just have to contiune to use the three templates under separate instances of word.

    If the above is true then I am happy to resolve the thread as solved.
    You misunderstand my remarks. It likely is possible. I am sorry I was not clearer. To me, though, it seems like you are approaching it from the wrong angle and making too much work out of it by ignoring things built into Word. When I was a Boy Scout, I learned to use friction or a lens to start a fire. However, I also learned to carry some matches! You are trying to rub sticks together when you have matches.

    I am still uncertain whether when you say template you are talking about Word template (a .dotm or .dotx file) rather than a pattern of text. Jargon matters for this.
    Templates in Microsoft Word

    Have you looked into Building Blocks?

  9. #9
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location
    I appreciate the analogy Chas as I too was a Boy Scout, but to continue along that same theme, this will be used by my co-workers of which many are not too computer savvy, or to continue along the Boy Scout thing have forgotten to bring their matches.

    As described in my OP the templates I refer to are macro enabled ones.

    I have looked at building blocks and could see that they could prove useful where various bits of repetition might be recognised. However, my scenario would not fall into that bracket as each usage of the template is almost certainly going to contain totally unique content where the user would be typing their own words and selecting their own options. Occasionally some of the content on a specific document can be used again and may only require alteration in some areas. Hence the usefulness of being able to go back and re edit.

    I already have in place the three separate macro enabled templates to be able to perform these functions, but would would ideally like to be able the user to select/edit any of these three just by a click off their respective ribbon button.

  10. #10
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    have a look here to see if this gives you any ideas. https://stackoverflow.com/questions/...stom-ui-ribbon
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  11. #11
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location
    I have been looking online for any pointers and had come across this page.

    The situation decribed in that post is along the lines to the message that I am receiving "The macro can't be found or has been disabled because of your Macro security settings".

  12. #12
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Quote Originally Posted by HTSCF Fareha View Post
    I appreciate the analogy Chas as I too was a Boy Scout, but to continue along that same theme, this will be used by my co-workers of which many are not too computer savvy, or to continue along the Boy Scout thing have forgotten to bring their matches.

    As described in my OP the templates I refer to are macro enabled ones.

    I have looked at building blocks and could see that they could prove useful where various bits of repetition might be recognised. However, my scenario would not fall into that bracket as each usage of the template is almost certainly going to contain totally unique content where the user would be typing their own words and selecting their own options. Occasionally some of the content on a specific document can be used again and may only require alteration in some areas. Hence the usefulness of being able to go back and re edit.

    I already have in place the three separate macro enabled templates to be able to perform these functions, but would would ideally like to be able the user to select/edit any of these three just by a click off their respective ribbon button.
    Building Blocks are much more flexible than you seem to be imagining. You can include Content Controls in them for people to fill in. If these are repurposed document property content controls, you can type something in one place in a document and have it automatically replicated in other places. Repeating Data Using Document Property Content Controls and Other Mapped Content Controls. For other mapped controls, they would have to be mapped to a point in the document template or document. Those based on the Doc Property controls work in any document and as such are suitable for global building blocks. Those based in the particular document template can likewise be used in documents based on the template. The Building Blocks Gallery Content Control can be a powerful tool.

    ----
    Switching gears, I do use hundreds of macro-enabled templates in my office and they are linked to a custom ribbon tab. That was a lot of work, a big project. It allows lower-level non-computer-savvy employees to access and use those templates. I again urge you to first explore the possibility of using building blocks.
    Here is the starting place for building a custom ribbon that can easily be transferred to multiple computers: Customize the Office Ribbon (It doesn't take rocket science) by Greg Maxey and Ribbon X download (archive) .

    KenyonFormsDocumentation.jpg
    Last edited by Chas Kenyon; 08-20-2023 at 01:54 PM. Reason: add screenshot

  13. #13
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    Quote Originally Posted by HTSCF Fareha View Post
    I have been looking online for any pointers and had come across this page.

    The situation decribed in that post is along the lines to the message that I am receiving "The macro can't be found or has been disabled because of your Macro security settings".
    You appear to be dealing with a different (and more common) problem. I suggest posting a separate question to get the best answers.

  14. #14
    Moderator VBAX Wizard Aussiebear's Avatar
    Joined
    Dec 2005
    Location
    Queensland
    Posts
    5,060
    Location
    Have a look here for the security of macros.https://support.microsoft.com/en-us/...e-16fed1a7e5c6
    Remember To Do the Following....
    Use [Code].... [/Code] tags when posting code to the thread.
    Mark your thread as Solved if satisfied by using the Thread Tools options.
    If posting the same issue to another forum please show the link

  15. #15
    VBAX Contributor
    Joined
    Jul 2020
    Location
    Sun Prairie
    Posts
    123
    Location
    I added the screenshot. Again, this is not a simple project but once it is set up it takes very little maintenance.
    KenyonFormsDocumentation.jpg
    Advantages to thus type of modification:
    • I've used it since Word 2010, in Word 2013, 2016, 2019, 2021, and 365. I currently use it concurrently in Word 2010 and 365 on one computer and in Word 2021 on another.
    • It is portable. It is easily added to another computer or user, without messing up any local customizations. It is not in the Normal template.
    • I can add or subtract templates simply by adding them to a folder or deleting / moving them from that folder. They will then appear in the menus. Dynamic Ribbon Menu by Greg Maxey


    Much simpler, you could record macros creating new documents from your template and put those on your QAT.
    Save the macros and corresponding QAT modifications in a separate template loaded as a Global Template, You would want the templates stored in your Workgroup Templates folder or subfolders. That makes it easier for the macros to find the templates on different computers.
    Modifying the Quick Access Toolbar (QAT) in Microsoft Word

  16. #16
    VBAX Mentor
    Joined
    Aug 2020
    Location
    Hampshire
    Posts
    402
    Location
    Quote Originally Posted by Chas Kenyon View Post

    ----
    Switching gears, I do use hundreds of macro-enabled templates in my office and they are linked to a custom ribbon tab. That was a lot of work, a big project. It allows lower-level non-computer-savvy employees to access and use those templates. I again urge you to first explore the possibility of using building blocks.
    Here is the starting place for building a custom ribbon that can easily be transferred to multiple computers: Customize the Office Ribbon (It doesn't take rocket science) by Greg Maxey and Ribbon X download (archive)
    Thanks Chas, this is exactly what I am trying to achieve, although my VBA experience is insufficient to comprehend most of what you are suggesting in your various post replies.

    I have used the Ribbon X to create the code for the buttons as per my original zip file on post #1. I had also come across Greg Maxey's page on the topic. I've also used Graham Mayor's excellent content control toolkit addin to ensure easy and accurate CC.

    I think that I am going to have to surrender at this point.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •