Re: Shortcut key doesn't run macro properly by Vivian
Vivian
Tue Feb 24 22:05:15 CST 2004
Thanks Steve,
I'll have to study ranges more!
Vivian
"Word Heretic" <myfullname@tpg.com.au> wrote in message
news:t7rn30dfctttqohmq91j1lj15kmq5aqii8@4ax.com...
> G'day "Vivian Carroll" <vcvc@aol.com>,
>
> I see numerous problems here. As you are using selection.find there is
> no guarentee there arent options set by the user via the GUI.
>
> 1) No Matchwildcards=False (@) is a wildcard
>
> 2) Tthe keypress seems to be interfering. Change Selection to MyRange
> and do this at the start
>
> Dim MyRange as Range
>
> Set MyRange = Selection.Range.Duplicate
>
> and at the end do a MyRange.Select
>
>
> It's just a workaround
>
>
> Steve Hudson - Word Heretic
> Want a hyperlinked index? S/W R&D? See WordHeretic.com
>
> steve from wordheretic.com (Email replies require payment)
>
>
> Vivian Carroll reckoned:
>
> >Hi Steve, Here's the entire macro...
> >
> > With Selection
> > .MoveRight Unit:=wdCharacter, Count:=1
> > With .Find
> > .ClearFormatting
> > .Text = "@"
> > .Forward = True
> > .Wrap = False
> > .Execute
> > End With
> > .Extend Character:="]"
> > End With
> >
> >
> >Vivian
> >
> >"Word Heretic" <myfullname@tpg.com.au> wrote in message
> >news:essf301a1t0v53if2le940rc9a3coc86l7@4ax.com...
> >> G'day "Vivian Carroll" <vcvc@aol.com>,
> >>
> >> I'll need to see a code sample
> >>
> >> Steve Hudson - Word Heretic
> >> Want a hyperlinked index? S/W R&D? See WordHeretic.com
> >>
> >> steve from wordheretic.com (Email replies require payment)
> >>
> >>
> >> Vivian Carroll reckoned:
> >>
> >> >Thanks, but I forgot to mention that collapsing to the end has the
same
> >> >result.
> >> >
> >> >"Word Heretic" <myfullname@tpg.com.au> wrote in message
> >> >news:p7ed30h8r0tnhm7d9mepq30tlifsf1mdoq@4ax.com...
> >> >> G'day "Vivian Carroll" <vcvc@aol.com>,
> >> >>
> >> >> dont move to the right, collapse to the end
> >> >>
> >> >> ensure you select the find result.
> >> >>
> >> >>
> >> >> Steve Hudson - Word Heretic
> >> >> Want a hyperlinked index? S/W R&D? See WordHeretic.com
> >> >>
> >> >> steve from wordheretic.com (Email replies require payment)
> >> >>
> >> >>
> >> >> Vivian Carroll reckoned:
> >> >>
> >> >> >In Word 2000 I have a macro in an Add-in template that finds the
next
> >@
> >> >> >symbol. It moves one character to the right before performing the
Find
> >in
> >> >> >case an @ symbol is currently selected.
> >> >> >
> >> >> >The macro works correctly when run from the VBE or from a toolbar
> >button.
> >> >> >However, when run from the Alt+2 shortcut, it does not move right
> >before
> >> >> >performing the Find (so once it has found the first @, it stays on
> >that @
> >> >> >each time Alt+2 is pressed). The weird thing is that if the
template
> >> >itself
> >> >> >is opened, Alt+2 works correctly on text inserted into the
template -
> >it
> >> >> >just doesn't work in other documents.
> >> >> >
> >> >> >What is the explanation for this and how can I make Alt+2 work
> >correctly?
> >> >> >
> >> >> >TIA,
> >> >> >Vivian Carroll
> >> >> >
> >> >>
> >> >
> >>
> >
>