Java Programming Home Page: Archive: Message #134

Date: Nov 17 2000 20:59:06 EST
From: "Java Programming" <javaProgramming-owner@listbot.com>
Subject: Java in VB!

Hi All,
I am trying to write a VB program for formatting
java. The Java is formatted according to a style called
"code". It would be really nice if all the keywords in Java
could be bold-faced.

Sorry to say the macro does not yet work. Can anyone
help?

Thanks!

Regards,
  - DL


Sub doJavaFormatting()
  styleCode ("class")
  styleCode ("interface")
  styleCode ("extends")
  styleCode ("implements")
  styleCode ("byte")
  styleCode ("char")
  styleCode ("short")
  styleCode ("int")
  styleCode ("long")
  styleCode ("float")
  styleCode ("double")
  styleCode ("boolean")
  styleCode ("while")
  styleCode ("for")
  styleCode ("import")
  styleCode ("new")
  styleCode ("static")
  styleCode ("void")
  styleCode ("private")
  styleCode ("public")
  styleCode ("protected")
  styleCode ("try")
  styleCode ("catch")
  styleCode ("finally")
  styleCode ("continue")
  styleCode ("break")
  styleCode ("return")
End Sub
Sub styleCode(keyword)
'
' styleCode Macro
' Macro recorded 11/17/00 by Douglas Lyon
'
    Selection.Find.ClearFormatting
    Selection.Find.Style = ActiveDocument.Styles("code")
    Selection.Find.ParagraphFormat.Borders.Shadow = False
    Selection.Find.Replacement.ClearFormatting
    Selection.Find.Replacement.Style = ActiveDocument.Styles("code")
    Selection.Find.Replacement.Font.Bold = True
    Selection.Find.Replacement.ParagraphFormat.Borders.Shadow = False
    With Selection.Find
        .Text = keyword
        .Replacement.Text = keyword
        .Forward = True
        .Wrap = wdFindContinue
        .Format = True
        .MatchCase = False
        .MatchWholeWord = False
        .MatchWildcards = False
        .MatchSoundsLike = False
        .MatchAllWordForms = False
    End With
    Selection.Find.Execute Replace:=wdReplaceAll
End Sub