Excel code to Word?

W

wayne

The following code has been copied from an Excel workbook
and the text "workbook" has been changed
to "ThisDocument".

When in excel and the workbook is opened it checks the
user name. If your on the list excel starts as normal if
not your out.

I've place this code in the code module for ThisDocument
but can't get the code to work.

Any ideas?



Dim User

Private Sub ThisDocument_Open()
User = Application.UserName
Application.DisplayAlerts = False
If (User = "Name1") Or (User = "Name2") Or (User
= "Name3") Then Beep Else Application.Quit
Application.DisplayAlerts = True

End Sub
 
P

Peter Hewett

Hi wayne

It should work, but you don't actually say what it is that's not working or if your
getting an error. This is pretty meager picking from which to diagnose your problem.

I don't wish to be rude but the code is a waste of time. You can circumvent startup
macros in a doument/template any number of ways. One of the easiest is to hold down the
Shift key when opening the document. This really affords you no extra privacy or
security.

HTH + Cheers - Peter
 
J

Jezebel

The problem is in the name: it should be called AutoOpen, and it needs to be
declared as public.
 

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