Question : Styles("No Spacing") universal code?

Hi experts

I have this code:
Selection.Style = ActiveDocument.Styles("No Spacing")

And on my computer it works great. But if I run it on anther with a Danish office on it the same code is this:
Selection.Style = ActiveDocument.Styles("Ingen afstand")

I don't what my code to think about the language version of the office system. Can't I use some more universal code than "No Spacing"?

Answer : Styles("No Spacing") universal code?

DCRAPACCESS,

I've just tried with a different version, (2003 rather than 2007) and that won't work.  Plan B.  Put the functgion below into a normal module and run from the immediate window as:

?namestyle("No Spacing")

Basically  to see if we can get the same response from both english and other version.  If the answers are both non zero then we have a chance ... I apologise for the loading on you but the general indications are what you ask cannot be done so i'm just trying a few guesstimates.

chris_bottomley
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
Function nameStyle(str As String) As Integer
Dim stile As Object
Dim looper As Integer

    nameStyle = 0
    For looper = 1 To ThisDocument.styles.Count
        If ThisDocument.styles(looper) = str Then
            nameStyle = looper
            Exit For
        End If
    Next

End Function
Random Solutions  
 
programming4us programming4us