Automatically open different workbooks depending on user account used.

E

Excel

There are two userrs on the same computer. When user 1 opens Excel,
I'd like oen workbook to automatically open. When user2 opens Excel,
I'd like a diffferent workbook to automatically open. Is this
possible? (Each user logs into Windows usning their uuser account.)

The computer is running windows XP pro and Excel 2007.

Thanks,
 
O

Otto Moehrbach

Something like this might work for you. This is untested. Post back if
this doesn't work for you. Place the following macro in the ThisWorkbook
module. You would need to change ThePath to your real path, the user
account names for Joe and Bill, and the names of the files you want opened.
HTH Otto
Private Sub Workbook_Open()
Dim ThePath As String
Dim FileName As String
ThePath = "C:\TheFolder\TheSubFolder"
If Environ("username") = "Joe" Then _
FileName = "FileForJoe.xls"
If Environ("username") = "Bill" Then _
FileName = "FileForBill.xls"
Workbooks.Open FileName:=ThePath & "\" & FileName
End Sub
 
G

Gord Dibben

Looking again at the original post, wouldn't it be just as easy for each user to
have a desktop shortcut to Excel with the workbook name in the command line?

"C:\Program Files\Microsoft Office\Exceldata\Joebook.xls"

Or you could place the shortcut in the user's Startup folder if you want Excel
to open with that workbook when user log in.


Gord Dibben MS Excel MVP
 

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