Re: message box when word opens

Tech-Archive recommends: Fix windows errors by optimizing your registry

From: Dragon (chrisja_at_nospam.acgov.org)
Date: 03/12/04


Date: Fri, 12 Mar 2004 21:21:33 GMT

Hi Charles. How would you code it if you want it to run everytime any
document is opened? Putting it in the Normal.dot is not an option.

I have tried the following, but it only works when it is a new document
opening when WORD is opening. I am trying to turn on the SHOW/HIDE function
whenever the user openes any document. I have placed the following code in
an Template that is in the Start-up folder.

Option Explicit
Dim OpenDocs As Long

Sub autoexec()

OpenDocs = Documents.Count
If OpenDocs > 0 Then
ActiveWindow.View.ShowAll = True
End If

End Sub

Thanks!

Dragon

"Charles Kenyon" <msnewsgroup@remove.no.spam.addbalance.com> wrote in
message news:OsK7uoP7DHA.3024@tk2msftngp13.phx.gbl...
> If you want it to run when Word is started, but not everytime a document
is
> opened, put your code in a macro in normal.dot or another global template.
> The macro must be named AutoExec.
>
> I tend to store macros named AutoExec or AutoOpen, AutoNew, AutoClose in a
> separate module named AutoMacros because otherwise I end up with
multiples.
> --
>
> Charles Kenyon
>
> See the MVP FAQ: <URL: http://www.mvps.org/word/> which is awesome!
> --------- --------- --------- --------- --------- ---------
> 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.
>
>
> "Mike" <csharpcoder@sbcglobal.net> wrote in message
> news:%23rtSz$N7DHA.2812@TK2MSFTNGP11.phx.gbl...
> > How can I get a macro to run when the user opens word template?
> > I want to display a message box when word is started.
> >
> > Here's my code i'm trying to execute;
> >
> > Private Sub Document_Open()
> > MsgBox "hey there"
> > End Sub
> > is this correct? I have it under
> > Normal --> Microsoft Word Object --> ThisDocument
> >
> > is that the correct spot to have this code, or should it be somewhere
> else?
> >
> >
> >
>
>
>



Relevant Pages

  • Re: Insert Text Left of Bulleted Style
    ... Thanks, Charles. ... I was able to record a macro that almost gave me what I ... the LISTNUM field is always at the mercy of the ... >>>> Although the LISTNUM field will produce a bullet if it follows one, ...
    (microsoft.public.word.vba.general)
  • Re: Unprotect/Protect template problem
    ... Try it on high with the provision to trust installed templates and Add-Ins. ... Charles Kenyon ... This message is posted to a newsgroup. ... do you know the specific registry value to change the macro security ...
    (microsoft.public.word.vba.general)
  • Petzolds MessageBoxPrintf
    ... In the second Chapter of Charles Petzold's "Programming Windows", 5th Edition, we have the following listing: ... // The va_start macro is usually equivalent to: ... int WINAPI WinMain (HINSTANCE hInstance, HINSTANCE hPrevInstance, ... I'm able to compile this with VC++ 7.1 without defining the UNICODE macro. ...
    (microsoft.public.dotnet.languages.vc)
  • RE: Inserting rows
    ... My sheet needs to insert a blank row under a number everytime it changes. ... "Luke" wrote: ... > "I have a spreadsheet that I need to insert a blank row under a number ... > is there a error in this macro or am I just not understanding macro's using ...
    (microsoft.public.excel.worksheet.functions)
  • Re: Spell check in locked form
    ... Thanks again Charles. ... I had a problem with the macro. ... Brian ... > This message is posted to a newsgroup. ...
    (microsoft.public.word.newusers)