Results 1 to 3 of 3
  1. #1
    Lounger
    Join Date
    Apr 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    VBA: Mac vs PC (Word 97 and Word 98)

    I have used the following code to preserve special characters when saving a Word file as plain text, and it works. VBA for Mac Word is supposed to be based on VB 5, like Word 97. It was hoping I could use this same code in Word 98, but it doesn't work. Among other things, it gets stuck in a loop. Can anyone help me fix it?


    '(Special characters are marked.)

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    With Selection.Find.Replacement.Font
    .Name = "Times"
    .Bold = False
    .Italic = False
    End With
    For x = 61474 To 61669
    Replace$ = "ChrW(" & Right$(x, 5) & ")"
    With Selection.Find
    .Text = ChrW(x)
    .Replacement.Text = Replace$
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Next x

    '(File is saved as plain text, and then as Word; special characters are restored.)

    Selection.Find.ClearFormatting
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Font.Name = "Symbol"

    For x = 61474 To 61669
    Replace$ = "ChrW(" & Right$(x, 5) & ")"
    With Selection.Find
    .Text = Replace$
    .Replacement.Text = ChrW(x)
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
    Next x



    Thanks.

    Jerry

  2. #2
    Super Moderator
    Join Date
    Jan 2001
    Location
    Melbourne, Victoria, Australia
    Posts
    3,852
    Thanks
    4
    Thanked 259 Times in 239 Posts

    Re: VBA: Mac vs PC (Word 97 and Word 98)

    Apart from tidying the code up a little, I can't suggest how you might make it run on a Mac but my questions are:
    Why use Right$? What about Str
    Does a Mac use unicode characters?
    Is there some other font issues?

    Here is the code I played with including a loop at the start to insert some samples of the unicode
    <pre>' For x = 61474 To 61669
    ' Selection.TypeText ChrW(x) & " "
    ' Next x
    '(Special characters are marked.)

    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Replacement.Font.Name = "Times"
    .Replacement.Font.Bold = False
    .Replacement.Font.Italic = False
    For x = 61474 To 61669
    Replace$ = "ChrW(" & Str(x) & ")"
    .Text = ChrW(x)
    .Replacement.Text = Replace$
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    Next x
    End With

    '(File is saved as plain text, and then as Word; special characters are restored.)

    With Selection.Find
    .ClearFormatting
    .Replacement.ClearFormatting
    .Replacement.Font.Name = "Symbol"
    For x = 61474 To 61669
    Replace$ = "ChrW(" & Str(x) & ")"
    .Text = Replace$
    .Replacement.Text = ChrW(x)
    .Forward = True
    .Wrap = wdFindContinue
    .Format = True
    .MatchCase = False
    .MatchWholeWord = False
    .MatchWildcards = False
    .MatchSoundsLike = False
    .MatchAllWordForms = False
    .Execute Replace:=wdReplaceAll
    Next x
    End With</pre>

    Andrew Lockton, Chrysalis Design, Melbourne Australia

  3. #3
    Lounger
    Join Date
    Apr 2002
    Posts
    38
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: VBA: Mac vs PC (Word 97 and Word 98)

    Andrew:

    Thanks for your help. Your cleaned-up code has the same problem. There are issues with unicode characters on the Mac.

    Jerry

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •