PDA

View Full Version : Solved: Install if certain user



Djblois
02-27-2007, 07:07 AM
I am trying to use code to install a button on my toolbar if it is a specific user on the computer. This is the code I am using and it doesn't work:

If Application.UserName = "dblois" Then
Set menuObject = Tbar.Controls.Add(Type:=msoControlPopup)
menuObject.Caption = "test"
End If

Bob Phillips
02-27-2007, 07:40 AM
Maybe

msoControlButton

Djblois
02-27-2007, 07:45 AM
sorry xld, right now I am was just using the popup to test it but it doesn't install that if the user name is dblois.

Bob Phillips
02-27-2007, 07:53 AM
Is dblois the application username or login name? If the latter, use

Environ("UserName")

Djblois
02-27-2007, 08:16 AM
xld. it was the application username that I was using. However, I can use your way and it works perfectly.

Djblois
02-27-2007, 08:46 AM
xld,

Actually, i forgot to test if it wouldn't install if the user name is not dblois and it still installs it. Right now it always installs it. this is the code I am using:

If Environ("Dblois") Then
Set menuItem = menuObject.Controls.Add(Type:=msoControlButton)
menuItem.OnAction = "runsummary"
menuItem.Caption = "Bob's BiWeekly Report"
End If

Djblois
02-27-2007, 08:50 AM
Sorry XLD, I thought it was working. Unfortunately, it is always installing now no matter the user name. Here is my code:

If Environ("Dblois") Then
Set menuItem = menuObject.Controls.Add(Type:=msoControlButton)
menuItem.OnAction = "runsummary"
menuItem.Caption = "Bob's BiWeekly Report"
End If

Bob Phillips
02-27-2007, 08:57 AM
Environ("UerName") = "Dblois"

Bob Phillips
02-27-2007, 08:58 AM
See my reply in the original thread.

lucas
02-27-2007, 09:04 AM
Threads merged

Djblois
02-27-2007, 09:21 AM
thank you lucas. I added the other one because since I put it complete, I didn't know if anyone would see it.

lucas
02-27-2007, 09:25 AM
We can mark it unsolved if you like....In fact I think you can do that using the thread tools. Edit and change the name of the thread by removing the solved part....let me know.

Djblois
02-27-2007, 09:30 AM
xld,

this is what I have now:

If Environ("username") = dblois Then
Set menuItem = menuObject.Controls.Add(Type:=msoControlButton)
menuItem.OnAction = "StartBobsBiWeekly"
menuItem.Caption = "Bob's BiWeekly Report"
End If

Unfortunately, it still isn't working

moa
02-27-2007, 09:42 AM
dblois should be in quotes.

Djblois
02-27-2007, 09:42 AM
thank you lucas and xld it is working now I needed to add " around dblois

Djblois
02-27-2007, 09:43 AM
lol, just notived your reply

Bob Phillips
02-27-2007, 09:43 AM
Why don't you just copy what I give you?

Djblois
02-27-2007, 09:54 AM
I would rather type it most of the code because it will help me remember it and get used to writing my own code.