regional settings' list seperator variable

W

ward

Hi,

I've run into the following annoying, stupid issue:

Using VBA I want to do a search for 2 or more empty
paragraphs and replace them by one paragraph. Therefore I
use the following code:

With tDoc.Range.Find
.ClearFormatting
.Text = "^13{2,}" <----- problem
.Replacement.Text = "^p"
.Forward = True
.Wrap = wdFindContinue
.Format = False
.MatchCase = False
.MatchWholeWord = False
.MatchAllWordForms = False
.MatchSoundsLike = False
.MatchWildcards = True
.Execute Replace:=wdReplaceAll
End With

The line ".text = "^13{2,}"" is giving me problems
however. Because the comma is a list seperator, as defined
in my MS Windows regional settings dialog box (Start,
control panel, regional settings, numbers), it works fine
on my computer.
But a colleague has his list seperator set to ";". Thus,
Word pops up saying it is not a valid expression.
I want my program to work, regardless of the regional
settings. So i tried to find a variable or constant which
contains the list seperator character (be it ",", ";" or
whatever) and create the .text string accordingly; but I
didn't find any.

Any (other) solutions,
thanks
Ward
 
H

Helmut Weber

Hi Ward,
how about creating your own function "Separator"?
Function Separator() As String
Dim r As Range
Set r = ActiveDocument.Range
Separator = ","
With r.Find
.text = " {2,}"
.MatchWildcards = True
On Error GoTo step1
.Execute
End With
Exit Function
step1:
Separator = ";"
End Function
Besides that, there may be a variety of solutions.
Greetings from Bavaria, Germany
Helmut Weber
"red.sys" & chr$(64) & "t-online.de"
Word 97, NT 4.0
 
K

Klaus Linke

You can improve on that a bit by determining the list separator in VBA:

Separator = Application.International(wdListSeparator)

Then, you can build the expression using that separator:
..text = " {2" & Separator & "}"

Clumsy, but should work...

Klaus
 
W

ward

"Application.International(wdListSeparator)"

that's what i was looking for!!
thanks and regards,
Ward
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top