Well, here is my AutoExec. Note the HaveABreak command which may be what
lets me manipulate.
Public Sub AutoExec()
'
On Error Resume Next
Dim sAddInsLocation As String
Dim i As Integer ' Counter to use in For structures
Dim n As Integer ' Number of Add-Ins being Loaded as True
Dim n1 As Integer 'Number of Add-Ins being Handled
Dim sAddInName(17, 2) As String ' holds Add-In names and whether or not
to Install
'
' Get rid of alert for SQL when running merge
Application.DisplayAlerts = wdAlertsNone
'
' Get general path length by subtracting startup folder
i = Len(Application.StartupPath) - Len("word 2003\startup")
'
' Assign location for utilities based on relative location to startup
folder
sAddInsLocation = Left(Application.StartupPath, i) & "Utilities\"
'
' Populate array and variables
'
sAddInName(1, 1) = "FileNamePath.dot"
sAddInName(2, 1) = "FirmInfo.dot"
sAddInName(3, 1) = "LegalToolbars.dot"
' sAddInName(5, 1) = "LegalToolbars.dot"
sAddInName(4, 1) = "KenyonMasterAdd-In01.dot"
sAddInName(5, 1) = "BoldItalStyles.dot"
sAddInName(6, 1) = "Letters.dot"
sAddInName(7, 1) = "AutoText from Normal.dot"
sAddInName(8, 1) = "NonPrintingApproximation.dot"
sAddInName(9, 1) = "PleadingMaster.dot"
sAddInName(10, 1) = "OutlineMaster 2.dot"
sAddInName(11, 1) = "ResetStyles.dot"
sAddInName(12, 1) = "KenyonMenus.dot"
sAddInName(13, 1) = "AT-Jails-WI.dot"
sAddInName(14, 1) = "Merge.dot"
sAddInName(15, 1) = "Textbridge 9.dot"
sAddInName(16, 1) = "FormFixer.dot"
sAddInName(17, 1) = "DateLoader.dot"
sAddInName(18, 1) = "Word Code Cleaner.dot"
'
n = 17 ' Number of Add-Ins being loaded as True
n1 = 18 ' Number of Add-Ins being loaded
'
For i = 1 To n
sAddInName(i, 2) = "True" ' set initial installed value to True for
first group
Next i
'
For i = n + 1 To n1
sAddInName(i, 2) = "False" ' set initial installed value to False
for rest
Next i
'
'
For i = 1 To n1
' If sAddInName(i, 1) = "KenyonMasterAdd-In01.dot" Then
' sAddInName(i, 2) = "False" ' don't install this add-in
' End If
AddIns.Add FileName:=sAddInsLocation & sAddInName(i, 1), _
Install:=sAddInName(i, 2)
' MsgBox Prompt:="Add-In " & sAddInName(i, 1) & " loaded. Number " &
i, _
Title:="Loading Add-Ins Message Box"
' HaveABreak (1)
Next i
' MsgBox "AutoExec MAIN macro in MyTools running."
Application.CommandBars("Add-Ins").Visible = False
'
Word.CommandBars("Envelope Toolbar").Visible = False
Word.CommandBars("Add-Ins").Visible = False
' Word.CommandBars("VersaCheck").Visible = False
' Word.CommandBars("_ VersaCheck").Visible = False
Word.CommandBars("MyTools MenuBar Chas").Visible = False
Word.CommandBars("MyTools MenuBar Chas").Enabled = False
Word.CommandBars("Formatting Toolbar Holder Chas").Visible = False
Word.CommandBars("Formatting Toolbar Holder Chas").Enabled = False
HaveABreak (6)
Application.CustomizationContext = ThisDocument.AttachedTemplate
With CommandBars("Macros")
.Left = 481
.Top = 0
.Height = 28
.Visible = True
.Position = 3
End With
With CommandBars("CDEVTools Kenyon")
.Left = 228
.Top = 23
.Height = 28
.Visible = True
.Position = 1
End With
Application.CustomizationContext = Application.normalTemplate
'
' View settings
'
With ActiveWindow
.DisplayHorizontalScrollBar = True
.DisplayVerticalScrollBar = True
.DisplayVerticalRuler = True
.DisplayScreenTips = True
With .View
.Draft = True
.ShowPicturePlaceHolders = False
.ShowFieldCodes = False
.ShowBookmarks = False
.FieldShading = wdFieldShadingWhenSelected
.ShowParagraphs = True
.ShowHiddenText = True
.ShowAll = False
.ShowDrawings = True
.ShowObjectAnchors = False
.ShowHighlight = True
End With
End With
'
' Get rid of adaptive menus
'
CommandBars.AdaptiveMenus = False
'
' Print View Set
'
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdNormalView
Else
ActiveWindow.View.Type = wdNormalView
End If
If ActiveWindow.View.SplitSpecial = wdPaneNone Then
ActiveWindow.ActivePane.View.Type = wdPrintView
Else
ActiveWindow.View.Type = wdPrintView
End If
On Error GoTo 0
End Sub
Private Sub HaveABreak(iSeconds As Integer)
Dim lPauseTime As Long
Dim lStart As Long
lPauseTime = iSeconds
lStart = Timer
Do While Timer < lStart + lPauseTime
DoEvents
Loop
End Sub
That is in there for a reason. I don't remember why I put it in, but it may
be what you are looking for.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by IgnoramusCharles,
I apologize for calling you Chris :)) That's my mistake because I
talked to a Chris in another newsgroup :)
I hope we are now finally to arrive to mutual understanding. One more
time, I understand what you're talking about, because I do exactly the
same thing, but I still have problems.
Just like you, I don't create the menu "on the fly". It's already
contained in the DOT add-in I am loading. The problem is that even
though the custom menu is there inside, for some reason it gets loaded
AFTER AutoExec is fired, unlike custom toolbars which are loaded BEFORE
AutoExec is fired. In other words, when AutoExec is fired, the DOT
addin is PARTIALLY loaded. That's the darn thing that causes me
problems.
What I want to do, again just like you, is only manipulate the
appeance/placement of the toolbar and menu that should already exist on
AutoExec, but my custom menu DOESN'T, only the toolbar does.
I hope the problem is clear now. Sorry for having been unclear through
previous posts :)
Post by Charles KenyonNot Chris, but...
How is custom menu created? by code?
I usually do not customize built-in menus directly. My customizations are
all on custom toolbars. I will then copy commands (and whole sub-menus) to
the built-in menus. Again, all of these are present in the template when it
is open, they are not done through code. All my code does is manipulate the
appearance / placement of toolbars that already exist.
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by IgnoramusChris,
Placed a MsgBox "Hello!" instruction in the first line of my AutoExec
1) If I simply open my addin template as a template file, then AutoExec
event is not fired at all.
2) If I load the addin by checking it in Tools -> Templates & Add-Ins
dialog, then the "Hello" message box is shown AFTER my custom toolbar
is loaded but BEFORE the custom menu is loaded. The custom submenu
appears after I click Ok button on the message box.
I'd prefer that my AutoExec fired AFTER ALL MY custom menus and
toolbars are loaded and shown. Have I missed something?
Post by Charles KenyonI work with 15 Add-Ins installed, at least three of which contain or
manipulate menus and toolbars. My AutoExec loads the other Add-Ins and then
postitions some of their menus. Again, the menus exist when the Add-In
loads, they are not created upon startup by code. If you simply open your
Add-In template (not load it as an Add-In) without running any code do your
custom menus exist?
--
Charles Kenyon
Word New User FAQ & Web Directory: http://addbalance.com/word
Intermediate User's Guide to Microsoft Word (supplemented version of
Microsoft's Legal Users' Guide) http://addbalance.com/usersguide
See also the MVP FAQ: http://word.mvps.org/FAQs/ which is awesome!
My criminal defense site: http://addbalance.com
--------- --------- --------- --------- --------- ---------
This message is posted to a newsgroup. Please post replies
and questions to the newsgroup so that others can learn
from my ignorance and your wisdom.
Post by IgnoramusHi Charles,
Actually, that's what I did - I created all menus and toolbars once via
Word UI and saved them in the DOT template. So I don't quite understand
the point of your advice. Perhaps you mean that I should assign the
event handlers to the OnAction properties of my buttons, in order to
avoid using AutoExec at all?
However, I still want to do some other initialization work with the
menu in AutoExec. For example, I want to remember references to menu
items to change their Enabled property on further document events. I
can't do this until the menu is actually created. Well, I think I can
do this on the first occasion, but I just wonder if I have overlooked
something with the AutoExec and toolbar/menu creation order?
Thanks