How to run Macro upon startup?

N

ninjaneer

Hi there!
This is my first time at working with Macros. I found the following on these
forums:

Sub OpenStylesPane()
Application.TaskPanes(wdTaskPaneFormatting).Visible = _
Not Application.TaskPanes(wdTaskPaneFormatting).Visible
End Sub

Now I want Word 2003 to run it everytime I open Word (It simply shows the
Styles Pane).

Thanks in advance!
Pieka
 
G

Graham Mayor

The macro toggles the display of the taskpane. If you merely want to open
it, you need to change the line to

Application.TaskPanes(wdTaskPaneFormatting).Visible = _
True

If you want it to open for each document then add the line to an autopen and
an autonew macro in normal.dot - see
http://www.gmayor.com/installing_macro.htm

However first see http://word.mvps.org/FAQs/Customization/ShowTaskPane.htm

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
N

ninjaneer

Thanks for the help Graham

I installed Task Pane Controller, but it does unfortunately not solve my
problem. It cannot be used to open the styles pane, only the getting started
or new document pane. Now I want to uninstall it, but I cant figure out how
to: I tried working through Control Panel's Programs and Features and it's
also not allowed to delete the macros that was created.

I also read through your tutorial. It is very good. Thanks. But I still
don't understand: If I write a macro and call it AutoOpen (as a module) will
it work automatically, or must I go scratch a bit deeper for the existing
AutoOpen macro?

Thanks again!
Pieka
 
G

Graham Mayor

The Taskpane controller takes the form of an add-in (TaskPaneController.dot)
which you will find in the Word Startup folder (location defined at tools >
options > file locations > startup). You can delete it from the folder with
Word (and Outlook) closed.

If you click ALT+F8 and you choose to display the Macros in Normal.dot. If
you already have macros called AutoOpen and AutoNew then edit those macros
and add the line at the end - before End Sub.

If they don't appear in the list create them

Sub AutoOpen()
Application.TaskPanes(wdTaskPaneFormatting).Visible = _
True
End Sub
Sub AutoNew()
Application.TaskPanes(wdTaskPaneFormatting).Visible = _
True
End Sub

An AutoOpen macro will run when you open an existing document
An AutoNew macro will run when you create a new document

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 
N

ninjaneer

Hi again

Yes, I discovered some of this already, but still, when I start up Word, it
creates a blank document, but with now styles pane shown.
If I then create a new document, the marco seems to run and the styles pane
appears. Same story with open.

Any advice on how to get it working at startup? AutoExec does not like the
command because nothing is open yet (the property is unavailable or
something).

Thanks for all the help so far!

Pieka
 
G

Graham Mayor

You can insert a short delay into the autoexec macro to give the document
time to load before displaying the taskpane eg

Sub AutoExec()
Application.OnTime _
When:=Now + TimeValue("00:00:01"), name:="ShowFormattingTP"
End Sub
Sub ShowFormattingTP()
Application.TaskPanes(wdTaskPaneFormatting).Visible = _
True
End Sub

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top