Re: autoexec in add-in? by mmalinsky
mmalinsky
Mon Dec 10 13:14:17 PST 2007
Gentlemen,
What I'm trying to ultimately accomplish is to have the numpad key
reassigned to a comma. I spend enough time typing numbers (rounded to
the nearest dollar) into Word to see efficiencies in having this key
reassignment. I have the reassignment part worked out, as can be seen
from the code. The code is saved in an add-in file in C:\Documents
and Settings\Administrator\Application Data\Microsoft\Word\STARTUP,
not in Normal.dot.
I created a toolbar that is attached to the add-in file. The toolbar
has a button that is supposed to turn the reassignment on and off. I
would like the button to have a state of msoButtonDown when this
feature is turned on and msoButtonUp when turned off. I further
wanted to have the keybinding clear itself upon closing or opening
Word (doesn't matter which) so that I would always start Word with
msoButtonUp and the numpad decimal as a decimal. This was to be a
visual cue to me so I would have to guess. As I stated, this works
fine outside of the paperless software we are using, but apparently
the add-in installed wit the paperless software kills the ability of
auto macros to fire. When Word files are accessed then closed from
within the paperless software, Word apparently remembers the last
value of the keybinding so if the numpad decimal was assigned to a
comma when the last Word document was closed, the numpad decimal is
still assigned to a comma when another Word document is opened.
Sorry for this being more than a couple of sentences, but I wanted to
make sure you knew all aspects. :-)
Thanks for the help.
Mike.
On Dec 9, 4:30 pm, zkid <z...@discussions.microsoft.com> wrote:
> Okay, back to you. You're just going to have to trust me on this one. The
> document management program has hijacked the autoexec subroutine, and most
> likely has also created hooks for the save, open, etc. operations.
>
> To verify this, generally the DM programs have an unprotected global
> template. Just go to the Word or Office startup directory, and retrieve
> their template. Now, search for autoexec (do a full project search in case
> there are multiple modules). All they have to do is create a sub called
> autoexec, and that prevents you from doing the same.
>
> The bottom line is that you will need to figure out another way to
> accomplish what you need. It is unclear to me why you wish to change the
> numpad period to a comma (if that is indeed what you're attempting to do),
> but you do not have autoexec at your disposal to do so.
>
>
>
> "mmalin...@gmail.com" wrote:
> > Actually, I just stumbled upon a new detail. This is a work computer
> > which has an third-party application that integrates with Word. This
> > third-party application, simply put, is a document organizer - a type
> > of paperless solution, if you will. The third-party application also
> > includes a Word add-in. When I open a Word document from outside of
> > the third-party app, my autoexec works fine. When I open a Word
> > document from within the third-party app, the autoexec does not fire.
> > I'm assuming it has something to do with the add-in related to third-
> > party app, which is password protected, so I cannot view it.
>
> > So the question I have now, is how can I ensure that my autoexec code
> > fires regardless of what other add-ins are doing, or am I just out of
> > luck?
>
> > Thanks.
>
> > On Dec 7, 5:30 am, "Tony Jollans" <My forename at my surname dot com>
> > wrote:
> > > Are you saying the AutoExec doesn't run at all? And you have this in your
> > > Startup folder?
>
> > > --
> > > Enjoy,
> > > Tony
>
> > > <mmalin...@gmail.com> wrote in message
>
> > >news:2c5cc3b7-ab4a-4a17-807c-71de27cf68be@x69g2000hsx.googlegroups.com...
>
> > > >I have the following code in an add-in. I've been having problems
> > > > with the key binding so I added an autoexec routine which I thought
> > > > would clear out the binding value when the add-in was loaded, but that
> > > > does not appear to be the case. I tested this by trying to get a
> > > > msgbox to pop-up when the add-in was loaded when Word was loaded and
> > > > nothing happened. Is there any way to get this to work?
>
> > > > Thanks,
> > > > Mike
>
> > > > Option Explicit
>
> > > > Sub AutoExec()
>
> > > > FindKey(BuildKeyCode(wdKeyNumericDecimal)).Clear
> > > > MsgBox FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory
>
> > > > End Sub
>
> > > > Private Sub AssignNumpadPeriodToComma()
>
> > > > Dim SavedState As Boolean
>
> > > > SavedState = ThisDocument.Saved
>
> > > > If FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory = -1
> > > > Then
> > > > CustomizationContext = NormalTemplate
> > > > KeyBindings.Add KeyCategory:=wdKeyCategoryMacro, _
> > > > KeyCode:=BuildKeyCode(wdKeyNumericDecimal), _
> > > > Command:="TypeAComma"
> > > > CommandBars("Helpers").Controls(1).State = msoButtonDown
> > > > Else
> > > > If FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory = 2
> > > > Then
> > > > FindKey(BuildKeyCode(wdKeyNumericDecimal)).Clear
> > > > CommandBars("Helpers").Controls(1).State = msoButtonUp
> > > > End If
> > > > End If
>
> > > > StatusBar = FindKey(BuildKeyCode(wdKeyNumericDecimal)).KeyCategory
>
> > > > ThisDocument.Saved = SavedState
>
> > > > End Sub
>
> > > > Sub TypeAComma()
>
> > > > Selection.TypeText ","
>
> > > > End Sub- Hide quoted text -
>
> > > - Show quoted text -- Hide quoted text -
>
> - Show quoted text -