Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 04-07-2021, 01:31 AM
rgros rgros is offline install language and macro language Windows 10 install language and macro language Office 2019
Novice
install language and macro language
 
Join Date: Jan 2021
Posts: 8
rgros is on a distinguished road
Default install language and macro language

I have a inhereted a macro that inserts a table if it is needed and checks after doing so if the table style is OK.


It fails sometimes, namely when the table is inserted. It appears that an error is raised on these lines:
Code:
        With Selection.Tables(1)
            If .style <> "Tabelraster" Then
                .style = "Tabelraster"
            End If
        End With
This used to work, but somehow the word install now is an english install, it used to be a dutch install, in which the style name for 'Table Grid' is 'Tabelraster'. The english install raises an error "Can't apply style"; changing 'Tabelraster' to 'Table Grid' in the macro makes it work again.
I need to fix this situation and I want to understand what option I have to repair this.
  • is a dutch install absolutely needed when the style names are dutch?
  • can the macro detect the language of the install and behave accordingly?
  • is there a way to write the macro in a way that is install language independant?
  • do I need to scan all macro files for dutch style names and translate them to english?
thanks for any insights about this!


Ruud

I have changed the above code to
Code:
        With Selection.Tables(1)
            Dim insLan
            insLan = Application.LanguageSettings.LanguageID(msoLanguageIDUI)
            If .style <> "Tabelraster" And .style <> "Table Grid" Then
                If (insLan = 1033) Then
                    ' English
                    .style = "Table Grid"
                else
                    ' Dutch
                    .style = "Tabelraster"
                End If
            End If
        End With
...which seems to work, but it feels lik the wrong way to go. What would be the best practice?
Reply With Quote
  #2  
Old 04-07-2021, 03:57 AM
gmayor's Avatar
gmayor gmayor is offline install language and macro language Windows 10 install language and macro language Office 2019
Expert
 
Join Date: Aug 2014
Posts: 4,101
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

How about


Code:
With Selection.Tables(1)
        On Error Resume Next
        .Style = "Tabelraster"
        If Err Then
            .Style = "Table Grid"
        End If
        On Error GoTo 0
    End With
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 04-07-2021, 04:27 AM
macropod's Avatar
macropod macropod is offline install language and macro language Windows 10 install language and macro language Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

How about:
Code:
Sub TblFmt()
Selection.Tables(1).Style = -155
End Sub
Should work for any language
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #4  
Old 04-07-2021, 04:52 AM
rgros rgros is offline install language and macro language Windows 10 install language and macro language Office 2019
Novice
install language and macro language
 
Join Date: Jan 2021
Posts: 8
rgros is on a distinguished road
Default

that sounds promising. Not depending on the installed language. Where can I read more about assigning numeric values to a style? I obviously use the wrong search terms to find a list of style codes.

thanks, Ruud
Reply With Quote
  #5  
Old 04-07-2021, 04:53 AM
macropod's Avatar
macropod macropod is offline install language and macro language Windows 10 install language and macro language Office 2016
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

See attached.
Attached Files
File Type: pdf List of Built-in Style Names in Word.pdf (65.8 KB, 9 views)
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #6  
Old 04-07-2021, 02:42 PM
Charles Kenyon Charles Kenyon is offline install language and macro language Windows 10 install language and macro language Office 2019
Moderator
 
Join Date: Mar 2012
Location: Sun Prairie, Wisconsin
Posts: 9,081
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

Also helpful may be Lene Fredborg's macro to create a list of local names.
Create List of Local Built-in Style Names
It gives the value as well as the local name. (I see this is also linked in the pdf that Paul provided.)
Reply With Quote
  #7  
Old 04-08-2021, 01:38 AM
rgros rgros is offline install language and macro language Windows 10 install language and macro language Office 2019
Novice
install language and macro language
 
Join Date: Jan 2021
Posts: 8
rgros is on a distinguished road
Default

Thank you all for your reactions. I'm convinced that with your suggestions I will succeed in making the macro's able to cope with both english and dutch installs. Great forum!

Ruud

Indeed the posted list of styles and the macro that Charles posted helped me out. I cannot find a way to mark this as solved, but solved it is.

Last edited by rgros; 04-08-2021 at 06:19 AM.
Reply With Quote
Reply

Tags
language, style language

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Having Difficulty Changing the Default Language and Spell Check Language JimG35 PowerPoint 0 10-30-2020 04:41 PM
install language and macro language installation of a language pack in Greek language for MS office 2016 professional plus/prob alsw Office 3 02-26-2018 08:49 PM
Macro to change language and untick 'do not check spelling' William E PowerPoint 2 05-13-2017 01:47 PM
install language and macro language Word macro - remove shading from active para. and assign language to it, keep text cursor position dejanm83 Word VBA 3 03-19-2017 02:36 PM
install new interface language shmu Office 4 09-21-2014 02:43 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:10 AM.


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