?
Solved

VB environ

Posted on 2010-11-28
12
Medium Priority
?
518 Views
Last Modified: 2012-05-10
Is is possible to replace the dropdown (Logged by) in the useform?

I was wondering if the computers username could be automatically displayed (Environ). It would just pick up the name of the PC as opposed to selecting a name in the dropdown.



userform.xls
0
Comment
Question by:Gazza83
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 5
  • 4
  • 2
  • +1
12 Comments
 
LVL 45

Assisted Solution

by:patrickab
patrickab earned 664 total points
ID: 34227013
Try:

TextBox1.Text = Environ("Username")
0
 
LVL 30

Expert Comment

by:SiddharthRout
ID: 34227054
I would also suggest changing the .Locked property to true so that no one can change anything in that textbox....
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227201
I think he wants Environ("ComputerName")
0
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227325
For future reference, pull up a command prompt and type SET and it will give you a list of all the environment variables currently in the system. I use this a lot because I always forget what they are all called.
0
 

Author Comment

by:Gazza83
ID: 34227327
Yeap would like to lock the cell down, have been experimenting with altering the existing code but no joy yet.

0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34227380
Lock what cell down? The textbox? Right click on it in the designer and hit properties and set Locked to true like Siddharth suggested. Also, if Environ doesn't work use VBA.Environ
To lock all the cells in the sheet just turn on protection. In the workbook_Open event do this
Private Sub Workbook_Open()
  Worksheets("Low Volume").Protect Password:="gary", UserInterfaceOnly:=True
End Sub

Open in new window

Then all the data will be protected from any changes except from within the code. Or you could protect the normal way (tools->protect sheet) and just unprotect and reprotect in the code.
0
 
LVL 37

Assisted Solution

by:TommySzalapski
TommySzalapski earned 668 total points
ID: 34227382
Here is a working example. Is this what you are after?
userform.xls
0
 
LVL 30

Accepted Solution

by:
SiddharthRout earned 668 total points
ID: 34228461
I think this is what you need ?

Sid
Sample.xls
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34228963
Tommy,

>I think he wants Environ("ComputerName")

As this would always be the same on any individual computer there would be little point in accessing it.

A password on the other hand would serve a purpose - probably.

Patrick
0
 
LVL 37

Expert Comment

by:TommySzalapski
ID: 34229901
Yeah, I realized that later. He said " It would just pick up the name of the PC" but then I saw the labels in the userform and decided he actually did want Username.
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34230321
It's always a problem interpreting the question... perhaps the asker will clarify matters.

Patrick
0
 
LVL 45

Expert Comment

by:patrickab
ID: 34235195
Gazza83 - Thanks for the points - Patrick
0

Featured Post

On Demand Webinar - Networking for the Cloud Era

This webinar discusses:
-Common barriers companies experience when moving to the cloud
-How SD-WAN changes the way we look at networks
-Best practices customers should employ moving forward with cloud migration
-What happens behind the scenes of SteelConnect’s one-click button

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
You need to know the location of the Office templates folder, so that when you create new templates, they are saved to that location, and thus are available for selection when creating new documents.  The steps to find the Templates folder path are …
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …
This Micro Tutorial demonstrates using Microsoft Excel pivot tables, how to reverse engineer competitors' marketing strategies through backlinks.

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question