paleoWordFan
Tue Jul 31 02:36:02 CDT 2007
Thanks for your answer Shauna. I figured that it may be a type mismatch
problem (which is a bug to me). But when I tried to correct the number in the
macro to numeric --
.Font.Position = 2.5
The same problem occurs. Macro runs it with 2 rather than 2.5. I know that
because when i click on the "Replace" command, the formating shown is Raised
2 points rather than Raised 2.5
How to over come this?
I am aware of the null filler option. But this is a specific conversion macro.
Thanks
/John
"Shauna Kelly" wrote:
> Hi
>
> The VBA help files show that the .Position property returns a Long integer,
> not a string. When you set the .Position as "2.5", Word will perform an
> implicit conversion, and convert this to a Long, which is 2.
>
> The real problem, however, is that through the user interface you can set
> the position (raised or lowered) in half points, and Word respects your
> choice. But the object model exposed to VBA only allows you to set it in
> whole numbers (because it's a long integer). So from what I can see, you can
> do the search-and-replace using the user interface, but you can't search for
> text raised 2.5pts in VBA.
>
> By the way, if you're only searching for formatting (and not text) you can
> specify that the .Text and .Replacement.Text is just "". And, you might want
> to set the .Continue property. So something like:
> With Selection.Find
> .Text = ""
> .Font.Position = 2
> .Replacement.Text = ""
> .Forward = True
> .Format = True
> .MatchWildcards = False
> .Wrap = wdFindContinue
> End With
>
> Hope this helps.
>
> Shauna Kelly. Microsoft MVP.
>
http://www.shaunakelly.com/word
>
>
> "paleoWordFan" <paleoWordFan@discussions.microsoft.com> wrote in message
> news:2CB69202-77FF-4B85-AFAB-E5C971D6702B@microsoft.com...
> >I am writing in regard to what appears to me to be a bug in the macro
> > processor for Word... though it may be that I am doing something wrong.
> >
> > The macro I have recorded/written is as follows:
> >
> > Sub changeRaisedtoSuperscript()
> > Selection.Find.ClearFormatting
> > Selection.Find.Replacement.ClearFormatting
> > With Selection.Find
> > .Text = "([0-9]*)"
> > .Font.Position = "2.5"
> > .Replacement.Text = "\1"
> > .Forward = True
> > .Format = True
> > .MatchWildcards = True
> > End With
> >
> > With Selection.Find.Replacement.Font
> > .Position = 0
> > .Size = 8
> > .Superscript = True
> > .Subscript = False
> > End With
> >
> > Selection.Find.Execute Replace:=wdReplaceAll
> > End Sub
> >
> > As you can see, this is a very simple macro to convert numeric characters
> > which are raise by 2.5 points (to simulate superscript) into real Word
> > superscripts.
> >
> > The trouble is that whenever the macro runs, the "2.5" is interpreted as
> > "2". I tried all means to get the ".5" into the macro without success. I
> > encountered this bug in Word 2003, and now in Word 2007.
> >
> > I would really appreciate if someone could suggest a solution to the
> > problem.
> >
> > Thanks
> >
> > /John
> >
>
>
>