Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
DiscussionsAccessExcelInfoPathOutlookPowerPointPublisherWord
DirectoryUser Groups
Related Topics
Outlook ExpressInternet ExplorerWindowsMS Server ProductsMore Topics ...

MS Office Forum / Word / Programming / July 2005

Tip: Looking for answers? Try searching our database.

Works in Excel but not Word?

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Wayne_Perth_WA - 18 Jul 2005 05:37 GMT
The follwing code works in excel but not in word?
It basically checks the user name.
checks to see if user name is either "Name1" or "Name2"
If the name is either of these it lets the document be open other wise the
document closes.

Any Ideas as to why it will not work?

Private Sub Document_Open()
   User = Application.UserName
   Application.DisplayAlerts = False
   If (User = "Name1") Or (User = "Name2") Then Beep Else Application.Quit
   Application.DisplayAlerts = True
End Sub
Jonathan West - 18 Jul 2005 11:02 GMT
Hi Wayne,

Various things might be wrong. Since you haven't indicated whether you have
stepped through the program and seen what happens, it is hard to be sure
what the exact problem is.

The most likely problem is that you have put the code in the wrong place.
For this code to be called, it needs to be in the ThisDocument module of the
document, or of the document's attached template.

Signature

Regards
Jonathan West - Word MVP
www.intelligentdocuments.co.uk
Please reply to the newsgroup
Keep your VBA code safe, sign the ClassicVB petition www.classicvb.org

> The follwing code works in excel but not in word?
> It basically checks the user name.
[quoted text clipped - 10 lines]
>    Application.DisplayAlerts = True
> End Sub
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.