Backslashes in Macros (Word 2001/J)

P

Philip Ronan

Hello,

I'm finding it impossible to insert backslashes from a macro in the Japanese
version of Word 2001. Whatever I do, they keep getting converted into yen
symbols. I've tried switching off the "Convert backslashes to yen symbols"
in Word preferences. I've also tried inserting "Chr$(92)". Whatever I do, I
get a yen symbol (the "alt+y" variety) instead of a backslash.

This is annoying because it's preventing me from building EQ fields. What I
want to do is use the following macro to draw a box around a selected word
by using the field code {EQ \x(...)}

Sub AddOutline()

If Selection.End > Selection.Start Then
Application.ScreenUpdating = False
a$ = Selection.Text
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:="EQ \x(" & a$ & ")", PreserveFormatting:=False

' Remove the extra space that is inserted in the field.
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.MoveLeft unit:=wdCharacter, Count:=2
Selection.Delete unit:=wdCharacter, Count:=1

' Move insertion point to the right of the field.
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.Start = Selection.End
Application.ScreenUpdating = True
End If
End Sub

All I get is a field that displays a yen symbol followed by the selected
word in brackets. To get a box I have to display field codes and manually
type over the yen symbol.

Has anyone found a workaround for this problem?

Phil
 
D

Dayo Mitchell

Hi Philip,

You should probably try posting in
Microsoft.public.word.international.features
Because no one else has answered, and the only suggestion I have (below)
seems quite feeble.

I assume you've installed the Combined Updater to bring Office up to Version
9.0.4 or SR 1?

It sounds as though you can manually type a backslash but the one the macro
inserts always changes to a yen? I wasn't quite clear. If that is the
case, a VBA group might also help--be sure to tell them you are on a mac and
have backwards VBA:
Microsoft.public.word.vba.general
Microsoft.public.word.word97vba

When Word does not remember your preferences or is acting otherwise oddly,
the first things to check are a corrupt Prefs file or a corrupt Normal
template. Extended directions below.

DM

Check for a corrupt Prefs file or corrupt Normal.dot.

To check for corrupt Prefs:

1. Quit Word.

2. Navigate to your Word Settings (9) file: You¹ll find it in
System Folder:preferences:Microsoft.

3. Rename the Word Settings (9) file and reopen Word. A new Word Settings
(9) file will be created.

4. If all is well, trash the old file. Since the Settings file stores all
your Word preferences, you will need to reset these.

5. If the fix did not work, quit Word, delete the new Settings file that
was created and rename the old file back.

To check for corrupt Normal.dot:

1. Quit Word.

2. Navigate to your Normal template: By default, this is in
Applications:Microsoft Office 2001:Templates. If you do not find it there,
use Edit:preferences:File locations:User Templates:Modify to reveal its
location.

3. Rename the Normal template (for example, to oldNormal) and reopen
Word. A new Normal template will be created.

4. Open Word and test it.

5. If all is now well, quit Word.

6. Say Yes if prompted to save the changes to your Normal template (so
you don¹t discard the new one you just made).

7. Copy over any important customizations, styles, macros or auto-texts
from the old Normal to the new using Organizer (under Tools). You will lose
your keyboard shortcuts, sadly, as they cannot be copied like this.

8. Trash the oldNormal template file.

9. If this did not cure your problem, quit Word, delete the new Normal
template, then rename the old Normal back.
 
P

Philip Ronan

Hello,

I'm finding it impossible to insert backslashes from a macro in the Japanese
version of Word 2001. Whatever I do, they keep getting converted into yen
symbols. I've tried switching off the "Convert backslashes to yen symbols"
in Word preferences. I've also tried inserting "Chr$(92)". Whatever I do, I
get a yen symbol (the "alt+y" variety) instead of a backslash.

I just thought I'd post the solution here in case anyone finds this thread
later.

I eventually discovered that a "real" backslash can be inserted by using the
character code 128 ("Ä"; a capital "A" with two dots above it). This doesn't
correspond to anything like a backslash in either the Windows or Mac
character sets, but there you go.

The following macro works:

---------[begin]---------

Sub AddOutline()
If Selection.End > Selection.Start Then
Application.ScreenUpdating = False
a$ = Selection.Text
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:="EQ Äx(" & a$ & ")", PreserveFormatting:=False

' Remove the extra space that is inserted in the field.
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.MoveLeft unit:=wdCharacter, Count:=2
Selection.Delete unit:=wdCharacter, Count:=1

' Move insertion point to the right of the field.
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.Start = Selection.End
Application.ScreenUpdating = True
End If
End Sub

---------[end]---------

Hope someone finds this useful

Phil
 
J

John McGhie [MVP - Word]

Thanks Philip:

It is really valuable for people to post back with the final solution to
their problem. As you correctly surmised, your solution will now be
available on the Internet and in the Microsoft help system "forever" :)

Cheers


from said:
Hello,

I'm finding it impossible to insert backslashes from a macro in the Japanese
version of Word 2001. Whatever I do, they keep getting converted into yen
symbols. I've tried switching off the "Convert backslashes to yen symbols"
in Word preferences. I've also tried inserting "Chr$(92)". Whatever I do, I
get a yen symbol (the "alt+y" variety) instead of a backslash.

I just thought I'd post the solution here in case anyone finds this thread
later.

I eventually discovered that a "real" backslash can be inserted by using the
character code 128 ("Ä"; a capital "A" with two dots above it). This doesn't
correspond to anything like a backslash in either the Windows or Mac
character sets, but there you go.

The following macro works:

---------[begin]---------

Sub AddOutline()
If Selection.End > Selection.Start Then
Application.ScreenUpdating = False
a$ = Selection.Text
Selection.Fields.Add Range:=Selection.Range, Type:=wdFieldEmpty, _
Text:="EQ Äx(" & a$ & ")", PreserveFormatting:=False

' Remove the extra space that is inserted in the field.
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.MoveLeft unit:=wdCharacter, Count:=2
Selection.Delete unit:=wdCharacter, Count:=1

' Move insertion point to the right of the field.
ActiveWindow.View.ShowFieldCodes = Not ActiveWindow.View.ShowFieldCodes
Selection.MoveRight unit:=wdCharacter, Count:=1
Selection.Start = Selection.End
Application.ScreenUpdating = True
End If
End Sub

---------[end]---------

Hope someone finds this useful

Phil

--

Please respond only to the newsgroup to preserve the thread.

John McGhie, Consultant Technical Writer,
McGhie Information Engineering Pty Ltd
Sydney, Australia. GMT + 10 Hrs
+61 4 1209 1410, mailto:[email protected]
 

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