Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 09-16-2022, 10:08 AM
Cosmo Cosmo is offline Removing CustomUI when saving word file from template Windows Vista Removing CustomUI when saving word file from template Office 2007
Competent Performer
Removing CustomUI when saving word file from template
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default



Quote:
Originally Posted by Charles Kenyon View Post
Place your Custom UI in a Global Template rather than in the Document template. It will be there when you produce your document on your system and will not be there when the document is used on another system.
You are using Documents.Add with a template base, correct?

If the CustomUI is specific to each template, then still place it in a separate template and load the template with the CustomUI as an Add-In when you are producing the document. Once you save the document, unload the Add-In.

There is no good reason I can imagine to be placing a CustomUI in a template for documents when you do not want it to be in the document. IMO you are doing things the hard way.


The whole idea of putting customizations in templates is to have them be in the documents produced from the templates.

Templates in Microsoft Word


Thanks for the response.

I'll look into that, but I don't understand why this has worked for me with multiple documents before? This seems like it will complicate things a bit, if I now have to provide 2 documents for our users to install, and make sure that both are in place, if I understand what you are suggesting. And I will need to get the proper file path to the correct file in the global template, since I can't just reference the template containing the content itself.
Reply With Quote
  #2  
Old 09-16-2022, 12:23 PM
Charles Kenyon Charles Kenyon is offline Removing CustomUI when saving word file from template Windows 11 Removing CustomUI when saving word file from template Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,529
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by Cosmo View Post
Thanks for the response.

I'll look into that, but I don't understand why this has worked for me with multiple documents before? This seems like it will complicate things a bit, if I now have to provide 2 documents for our users to install, and make sure that both are in place, if I understand what you are suggesting. And I will need to get the proper file path to the correct file in the global template, since I can't just reference the template containing the content itself.
Are your users using your custom UI or just the resulting document?
They are creating documents to go to someone else using your Custom UI?

If in code, you refer to ThisDocument instead of ActiveDocument it gives reference to the file holding the code.

Global templates go in the Word Startup Folder. I can give you code to identify this folder if you need it.
? Application.StartupPath in the Immediate Window identifies it.


Here is a macro
Code:
Sub ShowStartUpPath()
  ' Macro written by Charles Kenyon 2014-02-25
  ' Shows setting for Startup Folder location in Microsoft Word in a message box.
  '
  MsgBox _
    Prompt:="Your StartUp folder location is " & _ 
      Application.StartupPath & _
      "." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & ".", _
      Buttons:=vbOKOnly, _
      Title:="Current Startup Folder Setting Information"
   '
End Sub
Reply With Quote
  #3  
Old 09-16-2022, 02:09 PM
Cosmo Cosmo is offline Removing CustomUI when saving word file from template Windows Vista Removing CustomUI when saving word file from template Office 2007
Competent Performer
Removing CustomUI when saving word file from template
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
Are your users using your custom UI or just the resulting document?
They are creating documents to go to someone else using your Custom UI?
Mostly, they are using internal documents that can be sent across our company.

Quote:
Originally Posted by Charles Kenyon View Post
If in code, you refer to ThisDocument instead of ActiveDocument it gives reference to the file holding the code.
Yes, that's what I'm using in the 'Add' command, as mentioned in my original posting.

Quote:
Originally Posted by Charles Kenyon View Post
Global templates go in the Word Startup Folder. I can give you code to identify this folder if you need it.
[
That's where I have them loaded already. I have a template that I created a year ago that creates new documents without the customUI, as well as the one I'm working on now that does.

Perhaps I misunderstood what you meant by 'global template'. I was reading that as a separate template file with the UI and VBA code, and a separate template file with the content with no UI and VBA code. Currently, the template file has the content and the UI and VBA. It is stored in the 'Startup Folder' as mentioned in my original posting.

Quote:
Originally Posted by Charles Kenyon View Post
FONT=verdana,arial,helvetica]? Application.StartupPath in the Immediate Window identifies it.[/FONT]


Here is a macro
Code:
Sub ShowStartUpPath()
  ' Macro written by Charles Kenyon 2014-02-25
  ' Shows setting for Startup Folder location in Microsoft Word in a message box.
  '
  MsgBox _
    Prompt:="Your StartUp folder location is " & _ 
      Application.StartupPath & _
      "." & Chr(13) & Chr(10) & Chr(13) & Chr(10) & ".", _
      Buttons:=vbOKOnly, _
      Title:="Current Startup Folder Setting Information"
   '
End Sub
Reply With Quote
  #4  
Old 09-16-2022, 02:55 PM
Charles Kenyon Charles Kenyon is offline Removing CustomUI when saving word file from template Windows 11 Removing CustomUI when saving word file from template Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,529
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by Cosmo View Post
***

Perhaps I misunderstood what you meant by 'global template'. I was reading that as a separate template file with the UI and VBA code, and a separate template file with the content with no UI and VBA code. Currently, the template file has the content and the UI and VBA.
This is what I mean.
A global template that contains the UI modifications and any related code, separate from the document template that contains the content and document format/styles.
The global could also hold building blocks that can be used to create content.
I am assuming that your UI modification is done by editing the XML of the template, not through vba on-the-fly editing. (Customize the Office Ribbon (It doesn't take rocket science) by Greg Maxey )

A global template in the Startup folder shares the UI modifications with all other documents / templates but does not insert those mods in others. They can be used.
If this is only to work with certain document templates, those templates could load the Add-In upon creation of a document and then the document template's code could unload the Add-In when the new document is closed.
Reply With Quote
  #5  
Old 09-16-2022, 04:07 PM
Cosmo Cosmo is offline Removing CustomUI when saving word file from template Windows Vista Removing CustomUI when saving word file from template Office 2007
Competent Performer
Removing CustomUI when saving word file from template
 
Join Date: Mar 2012
Posts: 240
Cosmo is on a distinguished road
Default

Quote:
Originally Posted by Charles Kenyon View Post
This is what I mean.
A global template that contains the UI modifications and any related code, separate from the document template that contains the content and document format/styles.
The global could also hold building blocks that can be used to create content.
I am assuming that your UI modification is done by editing the XML of the template, not through vba on-the-fly editing. (Customize the Office Ribbon (It doesn't take rocket science) by Greg Maxey )

A global template in the Startup folder shares the UI modifications with all other documents / templates but does not insert those mods in others. They can be used.
If this is only to work with certain document templates, those templates could load the Add-In upon creation of a document and then the document template's code could unload the Add-In when the new document is closed.
Yes, the UI is done by editing the XML

Ok, so what you're saying is if i have 5 different document templates, I create the templates without code or the CustomUI, and another template with all of the code and CustomUI for all 5 documents?

Currently, i am using the 'Document_New()' event of the template (in the 'ThisDocument' Microsoft Word Objects space) to run the code to set up the document (shows a userform to collect data, and populates the document).

To move the code to a 'Master' template, I'd need to move this activation to an app event handler "App_NewDocument(ByVal Doc As Document)" event in the Master template, then I'd need to determine which template created the active document, and run the setup function(s) needed for that specific template?

Is this the proper workflow?

Edit: after thinking about this, i might be able to keep all of the code for the setup of the document in the content template, and move the rest of the UI specific code to a separate 'Master' since that's mostly for editing/updating the document once it's created. Theres's a 'New XXXX Document' button to create a new document from the specific template, but that would just need to create the document, and the rest of the code would work as usual.

I very much appreciate your assistance, and patience, with me.
Reply With Quote
  #6  
Old 09-16-2022, 12:31 PM
Charles Kenyon Charles Kenyon is offline Removing CustomUI when saving word file from template Windows 11 Removing CustomUI when saving word file from template Office 2021
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,529
Charles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant futureCharles Kenyon has a brilliant future
Default

Quote:
Originally Posted by Cosmo View Post
***

I'll look into that, but I don't understand why this has worked for me with multiple documents before?

You are the homeowner coming to the carpenter saying "I've used this hammer to drive screws for the last ten years but it isn't working now."

I do not know why it worked for you in the past and is not working now. I know you are using the wrong tool for the job.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Saving Notes View into Word Template caz46 PowerPoint 0 06-24-2015 01:29 AM
Removing digitally signing when saving plasma Word 0 05-26-2015 08:36 AM
Saving a template file dreamz Word VBA 10 06-26-2014 04:38 AM
Removing CustomUI when saving word file from template Looking for best way to remove VBA and CustomUI from a file via VBA Cosmo Word VBA 1 04-25-2014 06:19 PM
Update Document Template when Saving the Document File bjbercaw Word 3 11-16-2010 02:03 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 12:38 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft