Euro

M

MarcoPolo

I need to select the amount in Euro in a context like that:

Deliveries: Euro 500,00 till 500 km
Taxes: Euro 450,00
Total amount: Euro 1.450,00

i need to store into variables only the numbers in euro (500,00 450,00
1.450,00)
How can i store them, as the selection.move unit:=dWord is not working cause
comma is different in europe?
 
H

Helmut Weber

Hi,

have a look at this one, just to get you going.
Whether it is working or not,
depends on how consistent your text is.
I am assuming, e.g., that Euro is followed
by _one_ space. If you want to cover all
possible variations including typos,
this could become pretty complicated.

Sub Test()
Dim sTmp As String
Dim rDcm As Range
Set rDcm = ActiveDocument.Range
With rDcm.Find
.Text = "Euro "
.MatchCase = True
While .Execute
rDcm.Collapse direction:=wdCollapseEnd
While IsNumeric(rDcm.Next) Or _
rDcm.Next = "." Or _
rDcm.Next = ","
rDcm.End = rDcm.End + 1
rDcm.Select ' for testing preferably in single step mode
Wend
sTmp = rDcm.Text
MsgBox CSng(sTmp)
' result probably depending on local settings
rDcm.Collapse direction:=wdCollapseEnd
rDcm.End = ActiveDocument.Range.End
Wend
End With
End Sub

sTmp is a string, though.

If you need the value in a variable of type single,
we could continue with a function for converting
a string into a single, which works regardless
of regional settings.
 

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