|
|
|
date: Thu, 17 Jul 2008 10:12:08 -0700,
group: microsoft.public.mac.office.word
back
Client macros need converting
Version: 2004
Operating System: Mac OS X 10.4 (Tiger)
Processor: Intel
I'm working on a MacBook Pro, Intel processor, on OS 10.4.11, and using Word 2004 (v. 11.5.0). Client sends files that have lots of styles applied, which need to be changed to markup tags for the publisher. She's created a series of macros that will find the text in a given style, add the open and close tags, then select the text and move it to be within the set of tags. When I tried to run one of these macros, I got the "Compile error in hidden module: NewMacros" message. The client also sent one of the macros' text in email, which I've pasted below. I tried to run compile in VBE, which balked on the lines .MatchKashida = False / .MatchDiacritics = False / .MatchAlefHamza = False / .MatchControl = False, so I tried removing those. Next pass through it stopped at this line, which I do not think I can remove without losing some of the function I need:
If InStrRev(Selection, " ") = Len(Selection) Then
Specifically, it objected to InStrRev. At this point, I stopped trying to debug, and turned to this forum for help.
Is there any hope for converting this macro into a usable one for Word 2004, or should I just start over and try creating them on my own?
Thanks in advance,
Mary
Sub MarkCheckboxes()
'
' MarkCheckboxes Macro
' Macro recorded 1/16/2008 by LB
'
Selection.Find.ClearFormatting
Selection.Find.Style = ActiveDocument.Styles("checkboxes")
With Selection.Find
.Text = ""
.Replacement.Text = ""
.Forward = True
.Wrap = wdFindContinue
.Format = True
.MatchCase = False
.MatchWholeWord = False
.MatchKashida = False
.MatchDiacritics = False
.MatchAlefHamza = False
.MatchControl = False
.MatchWildcards = False
.MatchSoundsLike = False
.MatchAllWordForms = False
End With
Selection.Find.Execute
'If InStr(Selection, " ") <> 0 Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1
'End If
Selection.TypeText Text:="<check></check>"
'Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
'Selection.Extend
Selection.Find.Execute
If InStrRev(Selection, " ") = Len(Selection) Then
Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
End If
WordBasic.MoveText
Selection.MoveLeft Unit:=wdCharacter, Count:=9
WordBasic.OK
End Sub
date: Thu, 17 Jul 2008 10:12:08 -0700
author: unknown
Re: Client macros need converting
Eeeewwww.... Nasty :-)
All that line is doing is checking for a space at the end of the selection.
Try this:
If Selection.Range.Characters.Last = " " Then
The InStrRev function doesn't exist in Word 2004. All it is doing is
looking "backwards" along the selection for a space. If it finds one it
returns the character position in the string where it found the space.
If the character position returned is the same as the length of the
selection, then the last character is a space. That's a fairly laborious
way of doing it (but it works!).
The line I have sent you should work equally well.
Cheers
On 18/07/08 2:42 AM, in article 59b5473c.-1@webcrossing.caR9absDaxw,
"mtodeditor@officeformac.com" wrote:
> Version: 2004
> Operating System: Mac OS X 10.4 (Tiger)
> Processor: Intel
>
> I'm working on a MacBook Pro, Intel processor, on OS 10.4.11, and using Word
> 2004 (v. 11.5.0). Client sends files that have lots of styles applied, which
> need to be changed to markup tags for the publisher. She's created a series of
> macros that will find the text in a given style, add the open and close tags,
> then select the text and move it to be within the set of tags. When I tried to
> run one of these macros, I got the "Compile error in hidden module: NewMacros"
> message. The client also sent one of the macros' text in email, which I've
> pasted below. I tried to run compile in VBE, which balked on the lines
> .MatchKashida = False / .MatchDiacritics = False / .MatchAlefHamza = False /
> .MatchControl = False, so I tried removing those. Next pass through it stopped
> at this line, which I do not think I can remove without losing some of the
> function I need:
>
> If InStrRev(Selection, " ") = Len(Selection) Then
>
> Specifically, it objected to InStrRev. At this point, I stopped trying to
> debug, and turned to this forum for help.
>
> Is there any hope for converting this macro into a usable one for Word 2004,
> or should I just start over and try creating them on my own?
>
> Thanks in advance,
> Mary
>
> Sub MarkCheckboxes()
> '
> ' MarkCheckboxes Macro
> ' Macro recorded 1/16/2008 by LB
> '
> Selection.Find.ClearFormatting
> Selection.Find.Style = ActiveDocument.Styles("checkboxes")
> With Selection.Find
> .Text = ""
> .Replacement.Text = ""
> .Forward = True
> .Wrap = wdFindContinue
> .Format = True
> .MatchCase = False
> .MatchWholeWord = False
> .MatchKashida = False
> .MatchDiacritics = False
> .MatchAlefHamza = False
> .MatchControl = False
> .MatchWildcards = False
> .MatchSoundsLike = False
> .MatchAllWordForms = False
> End With
> Selection.Find.Execute
> 'If InStr(Selection, " ") <> 0 Then
> Selection.MoveLeft Unit:=wdCharacter, Count:=1
> 'End If
> Selection.TypeText Text:="<check></check>"
> 'Selection.MoveRight Unit:=wdWord, Count:=1, Extend:=wdExtend
> 'Selection.Extend
> Selection.Find.Execute
> If InStrRev(Selection, " ") = Len(Selection) Then
> Selection.MoveLeft Unit:=wdCharacter, Count:=1, Extend:=wdExtend
> End If
> WordBasic.MoveText
> Selection.MoveLeft Unit:=wdCharacter, Count:=9
> WordBasic.OK
> End Sub
--
Don't wait for your answer, click here: http://www.word.mvps.org/
Please reply in the group. Please do NOT email me unless I ask you to.
John McGhie, Microsoft MVP, Word and Word:Mac
Sydney, Australia. mailto:john@mcghie.name
date: Fri, 18 Jul 2008 19:11:23 +0930
author: John McGhie
|
|