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

Re: Word Macro Processor Bug? by Shauna

Shauna
Tue Jul 31 02:14:18 CDT 2007

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
>



Re: Word Macro Processor Bug? by paleoWordFan

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
> >
>
>
>

Re: Word Macro Processor Bug? by Russ

Russ
Tue Jul 31 02:54:46 CDT 2007

After recording a macro and looking at the results, it was
Selection.Font.Position = 2.5
Without the quote marks.

> 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
>

--
Russ

drsmN0SPAMikleAThotmailD0Tcom.INVALID


Re: Word Macro Processor Bug? by paleoWordFan

paleoWordFan
Tue Jul 31 03:06:06 CDT 2007

Yes, I put in the quotation marks because I was trying to get the macro to
work.

Either way --

Selection.Font.Position = 2.5

or

Selection.Font.Position = "2.5"

It does not work. Try it out. I believe it is a bug.

/John

"Russ" wrote:

> After recording a macro and looking at the results, it was
> Selection.Font.Position = 2.5
> Without the quote marks.
>
> > 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
> >
>
> --
> Russ
>
> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>
>

Re: Word Macro Processor Bug? by Klaus

Klaus
Tue Jul 31 06:01:35 CDT 2007

Yes, it is a bug that was introduced when the macro language changed from
WordBasic to VBA.
As Shauna said, .Position was wrongly defined as Long (that is, an integer).

WordBasic should still work:

With WordBasic
.EditFindClearFormatting
.EditReplaceClearFormatting
.EditFindFont Position:="2.5"
.EditFind Find:="", Format:=1, Wrap:=1
End With

Regards,
Klaus


"paleoWordFan" wrote:
> Yes, I put in the quotation marks because I was trying to get the macro to
> work.
>
> Either way --
>
> Selection.Font.Position = 2.5
>
> or
>
> Selection.Font.Position = "2.5"
>
> It does not work. Try it out. I believe it is a bug.
>
> /John
>
> "Russ" wrote:
>
>> After recording a macro and looking at the results, it was
>> Selection.Font.Position = 2.5
>> Without the quote marks.
>>
>> > 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
>> >
>>
>> --
>> Russ
>>
>> drsmN0SPAMikleAThotmailD0Tcom.INVALID
>>
>>



Re: Word Macro Processor Bug? by Klaus

Klaus
Tue Jul 31 06:09:34 CDT 2007

To change all text that's raised 2.5 pt to 3 pt:

With WordBasic
.EditFindClearFormatting
.EditReplaceClearFormatting
.EditFindClearFormatting
.EditFindFont Position:="2.5"
.EditReplaceFont Position:="3"
.EditReplace Format:=1, Wrap:=1, ReplaceAll:=True
End With

Then you can use VBA to do the rest...

Regards,
Klaus



Re: Word Macro Processor Bug? by paleoWordFan

paleoWordFan
Tue Jul 31 07:56:01 CDT 2007

Thank you very much, Klaus! I tried it and it works!

Regards

/John

"Klaus Linke" wrote:

> To change all text that's raised 2.5 pt to 3 pt:
>
> With WordBasic
> .EditFindClearFormatting
> .EditReplaceClearFormatting
> .EditFindClearFormatting
> .EditFindFont Position:="2.5"
> .EditReplaceFont Position:="3"
> .EditReplace Format:=1, Wrap:=1, ReplaceAll:=True
> End With
>
> Then you can use VBA to do the rest...
>
> Regards,
> Klaus
>
>
>