Results 1 to 7 of 7
  1. #1
    Star Lounger
    Join Date
    Jan 2001
    Location
    UK, Surrey
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Word templates - updating language and fields

    I have a normal.dotm template for Word that has a couple of things I can't seem to change.

    It opens with the default language being Spanish - when it should be English. I've tried opening the template, setting the default proofing language back to UK, and saving the template. This makes no difference - next time I open a new document it's the same.

    I can fix this by creating an autonew macro:

    Selection.WholeStory
    Selection.LanguageID = wdEnglishUK

    But that seems overcomplicated. What's going on?

    The "company" field in the properties can't be updated. The company name has changed; but the box stubbornly keeps the same field content. Similar problem. I could add something to the autonew to update the company document property, of course; but I'd rather understand why editing the properties in normal.dotm and saving it won't do the trick.

  2. #2
    2 Star Lounger
    Join Date
    Feb 2001
    Location
    Willow Grove, Pennsylvania, USA
    Posts
    196
    Thanks
    4
    Thanked 46 Times in 38 Posts
    The procedure you described for changing the language should work. The only other thing I can suggest is to check the file date/time after saving the template, to be certain that it was actually saved. The language change should 'dirty' the template and cause the prompt to save on closing if a manual save hasn't been done.

    The Company property is a whole other kettle of fish. I recommend Allen Wyatt's article, http://word.tips.net/T001755_Changin...pany_Name.html.

  3. #3
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,515
    Thanks
    3
    Thanked 143 Times in 136 Posts
    The issue your have is that the language settings for each paragraph come initially from the paragraph style applied but can be overridden by local formatting. The template will have no effect on the content if the content has already had local language formatting applied. The macro code you posted will change the existing content to spell check in UK English but won't change the language settings for content that you may later add if you change styles.

    The updating the company field in the template won't change EXISTING documents. It will change new documents created with the template but not ones that have already been created.
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  4. #4
    Silver Lounger Charles Kenyon's Avatar
    Join Date
    Jan 2001
    Location
    Madison, Wisconsin, Wisconsin, USA
    Posts
    1,699
    Thanks
    56
    Thanked 63 Times in 61 Posts
    Because somehow the company name on my computer got set to Hewlitt Packard (the computer manufacturer) I ended up putting an AutoNew macro in my normal.dotm that changed this property on new documents.

    Code:
    Sub AutoNew()
    '
    ' AutoNew Macro
    ' Change the company property in new documents from Hewlett Packard.
    '
    '   Call WriteProp(sPropName:="Author", sValue:="William Shakespeare")
    Call WriteProp(sPropName:="Company", sValue:="Kenyon Law Offices")
    End Sub
    
    Public Sub WriteProp(sPropName As String, sValue As String, _
          Optional lType As Long = msoPropertyTypeString)
    
    'In the above declaration, "Optional lType As Long = msoPropertyTypeString" means
    'that if the Document Property's Type is Text, we don't need to include the lType argument
    'when we call the procedure; but if it's any other Prpperty Type (e.g. date) then we do
    
    Dim bCustom As Boolean
    
      On Error GoTo ErrHandlerWriteProp
    
      'Try to write the value sValue to the custom documentproperties
      'If the customdocumentproperty does not exists, an error will occur
      'and the code in the errorhandler will run
      ActiveDocument.BuiltInDocumentProperties(sPropName).Value = sValue
      'Quit this routine
      Exit Sub
    
    Proceed:
      'We know now that the property is not a builtin documentproperty,
      'but a custom documentproperty, so bCustom = True
      bCustom = True
    
    Custom:
      'Try to set the value for the customproperty sPropName to sValue
      'An error will occur if the documentproperty doesn't exist yet
      'and the code in the errorhandler will take over
      ActiveDocument.CustomDocumentProperties(sPropName).Value = sValue
      Exit Sub
    
    AddProp:
      'We came here from the errorhandler, so know we know that
      'property sPropName is not a built-in property and that there's
      'no custom property with this name
      'Add it
      On Error Resume Next
      ActiveDocument.CustomDocumentProperties.Add Name:=sPropName, _
        LinkToContent:=False, Type:=lType, Value:=sValue
    
      If Err Then
        'If we still get an error, the value isn't valid for the Property Type
        'e,g an invalid date was used
        Debug.Print "The Property " & Chr(34) & _
         sPropName & Chr(34) & " couldn't be written, because " & _
         Chr(34) & sValue & Chr(34) & _
         " is not a valid value for the property type"
      End If
    
      Exit Sub
    
    ErrHandlerWriteProp:
      Select Case Err
        Case Else
       'Clear the error
       Err.Clear
       'bCustom is a boolean variable, if the code jumps to this
       'errorhandler for the first time, the value for bCustom is False
       If Not bCustom Then
         'Continue with the code after the label Proceed
         Resume Proceed
       Else
         'The errorhandler was executed before because the value for
         'the variable bCustom is True, therefor we know that the
         'customdocumentproperty did not exist yet, jump to AddProp,
         'where the property will be made
         Resume AddProp
       End If
      End Select
    
    End Sub
    I snagged the WriteProp procedure from the MVP website. It was written by Astrid Zeelenberg. It is well documented there.

    (This was necessary because I had hundreds of templates created with the Hewlett Packard stamp in them before I even noticed this.)
    Last edited by Charles Kenyon; 2013-11-23 at 18:58.
    Charles Kyle Kenyon
    Madison, Wisconsin

  5. #5
    Star Lounger
    Join Date
    Jan 2001
    Location
    UK, Surrey
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thank you!

    By editing the styles in my template document and ensuring all the paras in it had the paragraph style applied correctly I've sorted the language issue. New documents now appear in English, even after I've commented out the autonew code.

    But new documents based on the template still seem to keep the old "Company" field.

  6. #6
    Star Lounger
    Join Date
    Jan 2001
    Location
    UK, Surrey
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, Charles!

    I'll have a go at that IF I can't find a way to make a simple edit to the normal.dotm file work.

    Perhaps I'll have to check my code to see if somewhere, some time, I set the company field in code (I've been modifying these templates for nearly 20 years). But I don't think I did.

  7. #7
    Star Lounger
    Join Date
    Jan 2001
    Location
    UK, Surrey
    Posts
    55
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Thanks, re Wyatt's article - I'll have a look... I need to restart my system now, but I did find an instance of the old company name in the register, which I've updated. I hope that will do the trick.

    EDIT
    Despite updating the register, it STILL came up with the old organisation name.

    I have checked all the code in the autoexec and autonew macros too - it's not coded in VBA.
    Last edited by penglish; 2013-11-26 at 10:51. Reason: Update

Tags for this Thread

Posting Permissions

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