Left Function with a string containing back slash and asterisk

A

andreas

Dear Experts:

1) this is a code snippet from one of my macros. This snippet causes a
page field to be selected. I now would like to select just page fields
in arabic style not roman style.

How am I to do this? The coding lines under 2) do not work

1) This snippet works
....
If UCase(Left(Trim(f.Code), 4)) = "PAGE" Then
f.Select
.....

2) This lines do not work? Why?
....
If UCase(Left(Trim(f.Code), 12)) = "PAGE\*ARABIC" Then
f.Select
.....

Help is appreciated. Thank you very much in advance.
Regards, Andreas
 
M

macropod

Hi Andreas,

This approach should work - and more quickly too:
Sub Test()
Dim f As Field
With ActiveDocument
For Each f In .Fields
If f.Type = wdFieldPage And InStr(UCase(f.Code), "ARABIC") > 0 Then MsgBox "Arabic-Format Page Field"
Next f
End With
End Sub
 
A

andreas

Hi Andreas,

This approach should work - and more quickly too:
Sub Test()
Dim f As Field
With ActiveDocument
  For Each f In .Fields
    If f.Type = wdFieldPage And InStr(UCase(f.Code), "ARABIC") > 0 Then MsgBox "Arabic-Format Page Field"
  Next f
End With
End Sub

--
Cheers
macropod
[MVP - Microsoft Word]



andreas said:
Dear Experts:
1) this is a code snippet from one of my macros. This snippet causes a
page field to be selected. I now would like to select just page fields
in arabic style not roman style.
How am I to do this? The coding lines under 2) do not work
1) This snippet works
...
If UCase(Left(Trim(f.Code), 4)) = "PAGE" Then
       f.Select
....
2) This lines do not work? Why?
...
If UCase(Left(Trim(f.Code), 12)) = "PAGE\*ARABIC" Then
       f.Select
....
Help is appreciated. Thank you very much in advance.
Regards, Andreas- Hide quoted text -

- Show quoted text -

Dear macropod,

great coding! It is working as desired. Thank you very much for your
professional help. Best Regards, Andreas
 

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