Results 1 to 8 of 8
  1. #1
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Toronto, Canada, Ontario
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Autoexec Macro help (OFF2003 Wxp)

    I'd like to have two things happen when I open a file. I want a macro that closes all but two toolbars to run, and i want View Markup turned off. Word won't let me open the autoexec macro, so how can I do this?

    TIA,
    Michael

  2. #2
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    Please clarify what you mean by "Word won't let me open the autoexec macro"

    The following code should do what you're looking for. Change the "sToolbarsToShow" value according your needs. Where you place it and how you call it depends on whether you want this for all document, specific documents, etc.
    <pre>Sub ChangeViewSettings()
    On Error Resume Next
    Dim cbar As CommandBar
    Dim sToolbarsToShow As String

    ' Add/Remove toolbar names here, separated by "/" characters
    sToolbarsToShow = "/Menu Bar/Standard/Formatting/Reviewing/"

    ' Hide any toolbars that aren't in the list
    For Each cbar In Application.CommandBars
    If InStr(sToolbarsToShow, "/" & cbar.Name & "/") Then
    cbar.Visible = True
    Else
    cbar.Visible = False
    End If
    Next cbar

    ' Show markup
    Application.ActiveWindow.View.ShowRevisionsAndComm ents = True

    End Sub
    </pre>


  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    AutoExec runs only when Word first starts, so you probably don't need to worry about that one. To run a macro every time you open a document, create an AutoOpen or Document_Open procedure.

  4. #4
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Toronto, Canada, Ontario
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    I tried creating an Autoopen and a Dcoument_Open macro, and neither worked. The code in each was the following:

    Application.ActiveWindow.View.ShowRevisionsAndComm ents = False
    CommandBars("PDFMaker 6.0").Visible = False

    the first line I got from a post above, the second by recording the closing of the PDF toolbar. But, while running the AutoOpen macro achieves the result I want, it is not happening automatically.

    Thanks,
    Michael

  5. #5
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    Where are you storing the macro? Word has a certain sequence of priority, and runs the first AutoOpen it finds:

    (1) Document
    (2) Attached template
    (3) Normal.dot
    (4) Global templates in the order listed in the Templates... dialog (but not all Auto macros will run from a global template)

  6. #6
    2 Star Lounger
    Join Date
    Jan 2001
    Location
    Toronto, Canada, Ontario
    Posts
    144
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    It's in Normal.Dot, but something must be running after it. I really don't want the PDF toolbar there, and when the View Changes is turned on, things that are inserted always come up as changes. Grrr.

    Michael

  7. #7
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    I'll have to leave the toolbars to others.

    > things that are inserted always come up as changes

    Make sure to turn off the tracking of changes (e.g., <code>ActiveDocument.TrackRevisions = False</code>) before hiding the toolbar, or all sorts of nasty things are likely to happen in that document down the road.

  8. #8
    3 Star Lounger
    Join Date
    Apr 2004
    Location
    Boston, Massachusetts, USA
    Posts
    389
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Autoexec Macro help (OFF2003 Wxp)

    Hi Michael,

    Dealing with the Acrobat toolbar is a timing problem. The Acrobat Add-in loads after Normal, so even if you hide the toolbar from an autoexec macro in Normal, that macro runs before Acrobat loads the toolbar.

    Put the following two macros in your Normal template. If you've got a bunch of other Add-ins that load, you may need to increase the 3 and 5 in the AutoExec macro (they're in seconds).

    <pre>Sub HideAcrobatToolbar()
    CommandBars("PDFMaker 6.0").Visible = False
    End Sub
    '
    Sub AutoExec()
    Application.OnTime DateAdd("s", 3, Now), "HideAcrobatToolbar", 5
    End Sub
    </pre>


Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •