Can't set language default

User avatar
HansV
Administrator
Posts: 78527
Joined: 16 Jan 2010, 00:14
Status: Microsoft MVP
Location: Wageningen, The Netherlands

Re: Can't set language default

Post by HansV »

I assume you meant ThisDocument.
Best wishes,
Hans

snb
4StarLounger
Posts: 582
Joined: 14 Nov 2012, 16:06

Re: Can't set language default

Post by snb »

@HV

I did indeed. Text amended. Thanks for scrutinizing !

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

ErikJan wrote:
11 Apr 2024, 20:42
Normal.dotm - yes, of course. Sorry, you're right.

No, I'm (very) Dutch but I hate forced translations of originally English language terms in computer OS and Programs. So that's all English.
Writing documents however for personal purposes is obviously in Dutch (although I worked for an American company for 34+ years and there everything was (US) English)

I apologize but I don't understand your last paragraph. Can't I have VBA code somewhere that triggers when I create a new document (like auto-open in Excel a bit) and that simply sets the document language to Dutch?
You can try using the first two macros on my Article: https://answers.microsoft.com/en-us/mso ... 535d3ec15b.

Change the Language ID in both of them, then call them from an AutoNew macro.

One changes the language setting of all stories in a Word document to the designated language.
The second changes the language setting for all styles to the designated language.
I do not know that this will work.

I think starting new documents from a different template than the Normal.dotm template will, though. As far as I know this anomalous action of the operating system language only alters documents when they are created from the Normal template. [EDIT: It does this with new blank documents started from any template. It will also change the proofing language to that in the OS if you delete everything in the document.
Last edited by Charles Kenyon on 15 Apr 2024, 03:34, edited 1 time in total.

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

snb wrote:
12 Apr 2024, 18:25
create a new document.
Insert this code in the macromodule of 'ThisDocument'
Run the code (F5)
Now the normaltemplate is available as a document.
Make the proofing changes.
Close the normaltemplate and save its alterations.
You can check whether it has taken into effect by closing word, reopening it again and checking the proofing language.
I did all of that: no changes

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

Charles Kenyon wrote:
13 Apr 2024, 01:32
You can try using the first two macros on my Article: https://answers.microsoft.com/en-us/mso ... 535d3ec15b.

Change the Language ID in both of them, then call them from an AutoNew macro.

One changes the language setting of all stories in a Word document to the designated language.
The second changes the language setting for all styles to the designated language.
I do not know that this will work.

I think starting new documents from a different template than the Normal.dotm template will, though. As far as I know this anomalous action of the operating system language only alters documents when they are created from the Normal template.
I'm beginning to see that the problem is Normal.dotm (as you suggest).

Building on that... could we put code in Normal.dotm that actually loads an alternative NormalAlt.dotm instead?

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

I'm beginning to see that the problem is Normal.dotm (as you suggest).
The problem is not the Normal.dotm file, but rather how Word acts when creating a document from that template.
The designers apparently never thought that someone would want to have the default language in Word be different from any blank template in the Operating System. The coding for this is apparently deep enough that they are having trouble changing it. This is speculation on my part.
Building on that... could we put code in Normal.dotm that actually loads an alternative NormalAlt.dotm instead?
Yes.
I earlier suggested that you use a different templates to start your new documents.
I have two Add-Ins that address this. You are welcome to download them and adapt the code to your own. This is has a basic letterhead template with code so that when placed in the Word startup folder it becomes the default new document. It does not replace the Normal template. Neither involves making changes to the Normal template. The idea is putting the code in a separate Global template, which may or may not be the document template that will be used. You can (1) Allow Word to use the Normal template as its default but have an easy way to create a new document from another template including a QAT button or when you use Ctrl+N in Word. Another simply makes the new template the default that is used as the basis for new documents. These Add-Ins have both been in use for decades.
Last edited by Charles Kenyon on 14 Apr 2024, 13:59, edited 2 times in total.

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

From Default New Document Addin are the following macros:

Option Explicit

Code: Select all

Sub AutoExec()
    ' Charles Kenyon
    ' On Word Startup creates a new document based on this template rather than on Normal.dotm
    On Error GoTo NoOpenDoc
    ActiveDocument.Close SaveChanges:=False
NoOpenDoc:
    Documents.Add Template:=ThisDocument.FullName, DocumentType:=wdDocument, Visible:=True
    '   Print View
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    Else
        ActiveWindow.View.Type = wdPrintView
    End If
    ActiveDocument.Saved = True
End Sub

Code: Select all

Sub FileNewDifferent()
    ' Charles Kenyon
    '   On standard system to intercept Ctrl+N shortcut and create a new document based on this template
    '   In a different template from the distribution template, you need to modify the keyboard shortcut for Ctrl+N to run this macro
    On Error Resume Next
    Documents.Add Template:=ThisDocument.FullName, DocumentType:=wdDocument, Visible:=True
    If ActiveWindow.View.SplitSpecial = wdPaneNone Then
        ActiveWindow.ActivePane.View.Type = wdPrintView
    Else
        ActiveWindow.View.Type = wdPrintView
    End If
    ActiveDocument.Saved = True
End Sub
Here is a temporary link to a template that contains these. It is probably simpler than downloading the Add-In.
https://www.dropbox.com/scl/fi/3f5uurdd ... ex1na&dl=0
The template needs to be stored in the Word Startup Folder.

To have Ctrl+N work with this code in a different template, you would need to have the template open for editing, with the code existing in the template and assign the keyboard shortcut to the macro FileNewDifferent.
https://answers.microsoft.com/en-us/mso ... 5883735330

I am assuming that if you have such a template with the language setting of Dutch, that new documents created from it will also be set for Dutch.

Before going through the trouble of adding the code, etc. try simply creating a document with no text and formatting it with Dutch as the proofing language and then save as a template. If you create a new document from that template, is the starting proofing language in the new document Dutch, or English?

[Edit] :flee:
I just checked and the template cannot be blank; it must have something formatted as Dutch. I suggested having a Content Control so formatted and set to be removed when edited. Here is a temporary link to my test template, formatted for Spanish.
https://www.dropbox.com/scl/fi/35od3rgn ... jeyxr&dl=0
(The test template does not have the code, it is just to test that when a new document is created from the template, it uses the language setting in the template.)
Last edited by Charles Kenyon on 14 Apr 2024, 13:50, edited 1 time in total.

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

On the template one, I tested your example and that worked. Then I tried a template with just one space (as Dutch) and that worked as well.
Now to the next step...

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

I added one line to "DifferentDefault.dotm"

Code: Select all

MsgBox "Differentdefault AutoExec"
Just to see if and when it runs. When I run the file from my Desktop, it doesn't run.

Three questions

(1) When I place the file in my startup folder it runs TWICE... I don't get that. After execution, one file is open (but it's called Document2, proof that it was opened twice I guess).

(2) Also, if I look in the VBE editor, I see this:
2024-04-14 19_05_22-Microsoft Visual Basic for Applications - DifferentDefault - [NewMacros (Code)].png
I'm fine but it seems Normal is still loaded (maybe that's 'Normal' [sic] ?).
I've seen that files in the Startup folder cannot be opened: I get "Project is unviewable" (that's fine)

(3) if I ever would like to change my new "DifferentDefault.dotm", I should move it out of the startup folder (or else I can't edit). Open the dotm, edit it, save it and then move it back to the startup folder... correct?
You do not have the required permissions to view the files attached to this post.

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

ErikJan wrote:
14 Apr 2024, 17:11
I added one line to "DifferentDefault.dotm"

Code: Select all

MsgBox "Differentdefault AutoExec"
Just to see if and when it runs. When I run the file from my Desktop, it doesn't run.

Three questions

(1) When I place the file in my startup folder it runs TWICE... I don't get that. After execution, one file is open (but it's called Document2, proof that it was opened twice I guess).

(2) Also, if I look in the VBE editor, I see this:
2024-04-14 19_05_22-Microsoft Visual Basic for Applications - DifferentDefault - [NewMacros (Code)].png

I'm fine but it seems Normal is still loaded (maybe that's 'Normal' [sic] ?).
I've seen that files in the Startup folder cannot be opened: I get "Project is unviewable" (that's fine)

(3) if I ever would like to change my new "DifferentDefault.dotm", I should move it out of the startup folder (or else I can't edit). Open the dotm, edit it, save it and then move it back to the startup folder... correct?
When you Open the file from the desktop, AutoExec will not run. When you create a new document from the template, AutoExec will not run. It only runs when the template is loaded as an Add-In.

(1) It does not run twice. What the AutoExec does is tell any blank document created from Normal.dotm to go away and tells Word to create a new blank document from whichever template holds the AutoExec macro. AutoExec runs when the template is loaded as an Add-In. The template is loaded as an Add-In because it is in the Startup Folder. It is also the document template for the new document.

If you look at the MacroList, you will see both AutoExec and FileNewDifferent listed as available macros. Macros in global templates are available to run, but are not able to be edited while loaded in an Add-In. See https://www.addbalance.com/usersguide/t ... htm#Global for more about global templates.

(2) Yes, Normal is still loaded and still accessible in the vba Editor. It must be loaded for Word to work. If we could put text in the Normal template and still have it fully functional, we would not need the extra template. However, it loses some functionality when it contains any text. (It can hold AutoText and other Building Blocks, just not text or images in the document layers.) https://www.addbalance.com/usersguide/t ... htm#Normal

(3) To edit the code you should unload it as an Add-In and open it. You can unload it by clicking on the Templates button on the Developer Tab and unchecking it. You can also, with Word closed, move it out of the Startup Folder and then restart Word. Then open it. (I have simply opened Add-In templates while they are loaded and edited the code, but doing so is chancy. You can lose your edits.)

My Add-Ins also contain code where you can set a different template than the code holder to be the default template.

You should use the Content Control set to be deleted rather than a space.
If you type anything in the Content Control, you just have what you typed but it remains in the proofing language set.
If you have a blank space, the temptation is to delete that space. If you do without typing anything, you will be back at English.
Last edited by Charles Kenyon on 15 Apr 2024, 03:38, edited 1 time in total.

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

OK, I get it and I think it will work (thanks for you patience Charles :-)).

One thing that I still don't get: I reported that I added an MsgBox statement, I should have added that I did that as last line in your AutoExec.
If I open Word: I see the message I put in the MsgBox statement twice (the first time floating above an empty Document2 and the second time above an empty Document2). When all is done, I'm left with an empty document (in Dutch, so that works).
Seems to me that AutoExec is running twice then, right?

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

Could be. I don't know.

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

OK, if you add that line as last line in the AutoExec, do you get the same behavior (I want to exclude anything else being fishy on my side).

(Alternatively: if you open Word, you you see Document1 or Document2?)

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

Charles, I got it all to work. When I open Word, I see the Content Control message and the language is Dutch. I assigned Ctrl-N and that works as well.
The double run I'll take for granted: it's invisible and happens in the background anyway (but it's odd).
Final (?) question (and maybe this is a repeat, I'm sorry): if I make a change (other than the language) and save that in my Normal.dotm normally, will I see that change in my new documents of do I get the document as it is in the DifferentDefault.dotm that I use now?

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

ErikJan wrote:
16 Apr 2024, 15:12
Final (?) question (and maybe this is a repeat, I'm sorry): if I make a change (other than the language) and save that in my Normal.dotm normally, will I see that change in my new documents of do I get the document as it is in the DifferentDefault.dotm that I use now?
You must not save this to be your Normal.dotm template.
You cannot create a fully functional Normal.dotm template by saving another document or template with that name.
Your Normal.dotm template should not have any textual content, not even a blank space! No headers/footers or images! It would be much simpler to put the Content Control in your Normal template, but that is very unwise.
The specific functions I can think of that get trashed by putting any content in the Normal template's document layer are envelopes and labels but there probably are others. In addition, saving a different document as your Normal template eliminates any customizations you may have save there.

For more about the Normal template, its purposes and functions, see my writing at: https://www.addbalance.com/usersguide/t ... htm#Normal

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

Sorry... I (think I) know that. What I meant is e.g. changes to page margins

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

You can change the margins in the normal.dotm file.
What does that have to do with the language problem?
You can also change the margins in the different default template.

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

Sorry for the delay in my response.

I know my question is not directly about the language problem, but it is about the use of a different document template to solve that problem.

If I am e.g. in the "Page Setup", "Font" or "Paragraph" dialog boxes, there are buttons called "Set as Default". When clicking this, the settings in these dialog boxes are saved in the "Normal.Dotm" template.

In the way we now seem to have solved the language problem, there is code in another template ("DifferentDefault.dotm"). That code CLOSES the Normal.Dotm and then loads itself so the document now uses the saved (non-OS) language.

So as Normal.dotm is closed, how will the updates I saved to that document by pressing "Set as Default" be active in my new document which is based on "DifferentDefault.dotm" then???

Maybe that's crystal clear to you but I would thing that as we close the Normal.Dotm template, it's save settings are lost. I know I might be wrong here but I just don't get it.

Hope you understand my question better now

User avatar
ErikJan
BronzeLounger
Posts: 1253
Joined: 03 Feb 2010, 19:59
Location: Terneuzen, the Netherlands

Re: Can't set language default

Post by ErikJan »

Related to this topic (not to my last post): the language problem is fixed. But if I click on an existing document now, that document opens OK, but also a second empty document opens (with the language set correctly to Dutch).
I don't want that: if I open an existing document, all I want to see open is that document and nothing else.

(I must admit that I think that also happened before I started my default language journey, so this might be a different question in itself maybe)

User avatar
Charles Kenyon
5StarLounger
Posts: 620
Joined: 10 Jan 2016, 15:56
Location: Madison, Wisconsin

Re: Can't set language default

Post by Charles Kenyon »

ErikJan wrote:
22 Apr 2024, 18:56
Sorry for the delay in my response.

I know my question is not directly about the language problem, but it is about the use of a different document template to solve that problem.

If I am e.g. in the "Page Setup", "Font" or "Paragraph" dialog boxes, there are buttons called "Set as Default". When clicking this, the settings in these dialog boxes are saved in the "Normal.Dotm" template.

In the way we now seem to have solved the language problem, there is code in another template ("DifferentDefault.dotm"). That code CLOSES the Normal.Dotm and then loads itself so the document now uses the saved (non-OS) language.

So as Normal.dotm is closed, how will the updates I saved to that document by pressing "Set as Default" be active in my new document which is based on "DifferentDefault.dotm" then???

Maybe that's crystal clear to you but I would thing that as we close the Normal.Dotm template, it's save settings are lost. I know I might be wrong here but I just don't get it.

Hope you understand my question better now
The code does NOT close the Normal.dotm template, which remains loaded and in the background in all Word sessions.
It closes any new document that was created based on the Normal template as part of Word starting.

When you click the option for new documents based on the template, I am unsure whether or not the change goes to the Normal template or the attached template. I expect the attached template. You can certainly try it and see.