View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Premanand Sethuraman Premanand Sethuraman is offline
external usenet poster
 
Posts: 22
Default How to make Computer name as a Password by VBA


Lot of Thanks to you Mike.
Yes it is now working perfrectly as per your guidance.
Thank you so much for introducing the function of Environ.

Regards,
Premanand.S

"Gord Dibben" wrote:

When you say "my computer name" do you mean your logon username or the
Computer Name?

To return Computer Name

MsgBox Environ("computername")


Gord Dibben MS Excel MVP

On Thu, 24 Jul 2008 20:53:01 -0700, Premanand Sethuraman
wrote:

Dear Mike,
Thanks for your reply.
I used the Environ Functrion in my coding as per your suggestions but it is
still saying "Incorrect Password"
My computer name is "env_mktl_prem"
Is it because of "Underscore" sign it is showing "Incorrect Password"?
THis is my coding

Private Sub CommandButton1_Click()
Dim myfile As String
Dim c As Range
Set c = Worksheets("Technical offer").Range("A7")
myfile = ActiveWorkbook.Name
If TextBox1.Text < Environ("Username") Then
UserForm1.Hide
MsgBox ("Incorrect Password")
Else
If c = 0 Then
MsgBox ("Please Enter the data of BagFilter and then use this button for
generating Output")
Else
Application.ScreenUpdating = False
Application.StatusBar = "PLEASE WAIT... " & Worksheets("HomePage").Cells(6,
9).Text
Application.OnTime Now + TimeSerial(0, 0, 5), "ClearStatusBar"
Sheets("Costing").Activate
Range(Cells(1, 1), Cells(71, (c * 3 + 2))).Select
.........
...........
End if
End if
End sub


Prem.

"Mike H" wrote:

Hi,

because you don't give too much detail it's hard to be precise but this may
get you going in the right direction.

Private Sub CommandButton1_Click()
response = InputBox("Enter password")
If response < Environ("Username") Then
MsgBox "Incorrect, You must enter you logon username"
Else
MsgBox "Password accepted"

End If
End Sub

Mike

"Premanand Sethuraman" wrote:

Dear All,
I 've made a program in which if the user click a button a userform will
form and it will ask for a Password.
Person should write Password in the textbox in Userform.
I want to accept the password of the Computer name (Log in name).
Will anyone help me how to sort out.

Thanks
Prem.