Results 1 to 9 of 9
  1. #1
    New Lounger
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Hi there,

    We use Word documents created in the French version of Word 2003. When colleagues with the English version of Word 2003 work on the same documents, they of course get "error style not defined" in the headers, footers, TOC and so on. They have to send the documents back to French colleagues to get them updated.

    One suggestion is to allow the user to choose between attaching the English or French templates when you open the document. VB can detect the language of the installation programme and user interface ( using the Application.LanguageSettings.LanguagePreferredForE diting property) on condition that the languages are in the MSOffice Language Settings.

    Does anyone have any experience with this problem? Are the Language versions of Word 2003 insurmountable obstacles?

  2. #2
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts
    I'm no Word programmer, but I'd do something like this:

    Add code to the document's ThisDocument object in the Visual Basic Editor:
    Code:
    Private Sub Document_Open()
    	ActiveWindow.View.ShowFieldCodes = True
    	Selection.Find.ClearFormatting
    	Selection.Find.Replacement.ClearFormatting
    	With Selection.Find
    		.Text = "STYLEREF ""English Name Of Style"
    		.Replacement.Text = "STYLEREF ""French Name Of Style"
    'Or vice versa!
    		.Forward = True
    		.Wrap = wdFindAsk
    		.Format = False
    		.MatchCase = False
    		.MatchWholeWord = False
    		.MatchWildcards = False
    		.MatchSoundsLike = False
    		.MatchAllWordForms = False
    		.Execute Replace:=wdReplaceAll
    	End With
    	ActiveWindow.View.ShowFieldCodes = False
    	Me.Fields.Update
    End Sub
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  3. #3
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Welcome to the Lounge!

    Do the users have other differences than the interface language, such as the system settings for date format, decimal separator?

  4. #4
    New Lounger
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='pieterse' post='800102' date='27-Oct-2009 09:37']I'm no Word programmer, but I'd do something like this:

    Add code to the document's ThisDocument object in the Visual Basic Editor:
    Code:
    Private Sub Document_Open()
    	ActiveWindow.View.ShowFieldCodes = True
    	Selection.Find.ClearFormatting
    	Selection.Find.Replacement.ClearFormatting
    	With Selection.Find
    		.Text = "STYLEREF ""English Name Of Style"
    		.Replacement.Text = "STYLEREF ""French Name Of Style"
    'Or vice versa!
    		.Forward = True
    		.Wrap = wdFindAsk
    		.Format = False
    		.MatchCase = False
    		.MatchWholeWord = False
    		.MatchWildcards = False
    		.MatchSoundsLike = False
    		.MatchAllWordForms = False
    		.Execute Replace:=wdReplaceAll
    	End With
    	ActiveWindow.View.ShowFieldCodes = False
    	Me.Fields.Update
    End Sub
    [/quote]


    Thanks for such a speedy reply! Something like this code would take care of replacing a style. It would then have to be repeated for every style in the TOC, headers and footers that was not common to both language versions.

  5. #5
    New Lounger
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    [quote name='HansV' post='800107' date='27-Oct-2009 09:45']Welcome to the Lounge!

    Do the users have other differences than the interface language, such as the system settings for date format, decimal separator?[/quote]


    They probably do, though our templates try to standardize date formats and such things as much as possible. Can VB detect the language of a macro? Theoretically, it must be possible, mustn't it, because the VBA statements, methods, properties, and so on, are in English regardless of the localized language?

  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    VBA is always in English, but differences in system settings can lead to problems with fields in the document:
    - Some arguments in field codes are separated by the list separator, this is the comma in English systems but a semicolon if the comma is used as decimal separator.
    - Date formats in field codes are literal strings; this may cause problems if users have different date formats (m/d/y vs d/m/y vs y/m/d).

  7. #7
    Platinum Lounger
    Join Date
    Feb 2001
    Location
    Weert, Limburg, Netherlands
    Posts
    4,812
    Thanks
    0
    Thanked 0 Times in 0 Posts
    It would depend on specifically which fields you have in the document which depend on localisation what exactly the VBA code would have to do.
    I'm no WOrd expert though, Word fields are magic to me too :-)
    Jan Karel Pieterse
    Microsoft Excel MVP, WMVP
    www.jkp-ads.com
    Professional Office Developers Association

  8. #8
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts
    [quote name='khjackso' post='800081' date='27-Oct-2009 21:57']We use Word documents created in the French version of Word 2003. When colleagues with the English version of Word 2003 work on the same documents, they of course get "error style not defined" in the headers, footers, TOC and so on. They have to send the documents back to French colleagues to get them updated.

    Does anyone have any experience with this problem? Are the Language versions of Word 2003 insurmountable obstacles?[/quote]
    Depending on what exactly you are trying to achieve, the language versions should not be too large an issue. The error you describe would only appear when you run a macro - if you don't use macros then there is nothing to stop you editing the file.

    One possibility is to use style aliases to merge two different style names. For instance if your style is named 'Normal,ordinaire' then the macro could use either of these words to determine the style.

    Another possibility is to use the wdBuiltinStyle constants which appear to remain constant across languages. There appears to be over 130 of these constants which should be enough to give you variety in your style names. A code sample in my Word 2007 help file that would appear to work across all languages is
    Code:
    Dim i as integer
    For i = 1 To ActiveDocument.Paragraphs.Count
    	If i Mod 2 = 0 Then
    		ActiveDocument.Paragraphs(i).Style = wdStyleNormal
    	Else: ActiveDocument.Paragraphs(i).Style = wdStyleHeading3
    	End If
    Next i
    Andrew Lockton, Chrysalis Design, Melbourne Australia

  9. #9
    New Lounger
    Join Date
    Oct 2009
    Posts
    4
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Quote Originally Posted by Andrew Lockton View Post
    Depending on what exactly you are trying to achieve, the language versions should not be too large an issue. The error you describe would only appear when you run a macro - if you don't use macros then there is nothing to stop you editing the file.

    One possibility is to use style aliases to merge two different style names. For instance if your style is named 'Normal,ordinaire' then the macro could use either of these words to determine the style.

    Another possibility is to use the wdBuiltinStyle constants which appear to remain constant across languages. There appears to be over 130 of these constants which should be enough to give you variety in your style names. A code sample in my Word 2007 help file that would appear to work across all languages is
    Code:
    Dim i as integer
    For i = 1 To ActiveDocument.Paragraphs.Count
    	If i Mod 2 = 0 Then
    		ActiveDocument.Paragraphs(i).Style = wdStyleNormal
    	Else: ActiveDocument.Paragraphs(i).Style = wdStyleHeading3
    	End If
    Next i



    Hi Andrew,

    The wdBuiltinStyle constants looks like an excellent solution. I'm going to run a small test, and then if all goes well, rename the styles. Fingers crossed, and many thanks! I'll keep you posted.

Posting Permissions

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