PDA

View Full Version : Solved: Document_Open Event



Justinlabenne
09-05-2004, 09:20 PM
I dont use Word often but I was wondering if this was possible. I can't seem to figure out if there are Auto_Open / Auto_Close for Word. Document Open?
I wanted to hide some of the command bars when a specific Word Doc is opened and then unhide on closing. (Like I can easily figure out in excel) I can get it to Work using buttons from Control Toolbox. Any way to make it happen on an open event?

Justin Labenne

Anne Troy
09-05-2004, 09:23 PM
Sure.
Put the code in ThisDocument and make it"

Private Sub Document_Open()

Now, if you're using a template, you'll want to ALSO put the code into:

Private Sub Document_New()

Please don't forget to put the toolbars back on:

Private Sub Document_Close()

Justinlabenne
09-05-2004, 09:36 PM
Dont Know what im missing. Here is the code I have in the ThisDocument code module:
Private Sub Document_Close()
With Application
.CommandBars("Standard").Visible = True
.CommandBars("Formatting").Visible = True
.CommandBars("Drawing").Visible = True
End With
End Sub
''''
Private Sub Document_Open()
With Application
.CommandBars("Standard").Visible = False
.CommandBars("Formatting").Visible = False
.CommandBars("Drawing").Visible = False
End With
End Sub

I close the Document and reopen and all toolbars are still visible? Im sure its me. Never done VBA in Word ever.

Anne Troy
09-05-2004, 09:48 PM
They both work just fine for me.

Dude...you got your Macro security set to high?
Better set it to medium or low BEFORE you open the document.

:)

Anne Troy
09-05-2004, 09:50 PM
By the way....

In the VBE, normal.dot is Word's default template. Anything you put in there happens all the time. However, normal.dot doesn't have a document_open when you launch Word; it only has a document_new.

So, make sure you're putting this in ThisDocument of the DOCUMENT, and not in Normal.dot.

Dot it? I mean...got it?
Hee hee...
I crack myself up.
:bore

Justinlabenne
09-05-2004, 09:57 PM
Yes, that was absolutely it. Right before I came back to check this post I realized i had never used Macros for Word here at home, I had also never been prompted to Enable. Thank you so much much for your help. It worked after I stopped and thought for a second. (Actually an Hour)

Anne Troy
09-05-2004, 10:02 PM
It works?

GREAT!!

:cool