-
Solved: Document_Open Event
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
-
Sure.
Put the code in ThisDocument and make it"
[vba]Private Sub Document_Open()[/vba]
Now, if you're using a template, you'll want to ALSO put the code into:
[vba]Private Sub Document_New()[/vba]
Please don't forget to put the toolbars back on:
[vba]Private Sub Document_Close()[/vba]
-
Dont Know what im missing. Here is the code I have in the ThisDocument code module:
[vba]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[/vba]
I close the Document and reopen and all toolbars are still visible? Im sure its me. Never done VBA in Word ever.
-
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.
-
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.
-
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)
-
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules