ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Environ () Function (https://www.excelbanter.com/excel-programming/429357-environ-function.html)

Ayo

Environ () Function
 
Can someone explain to me how the Environ () works. I saw it been used in
another example code here as follows:

Private Sub Workbook_Open ()
Dim myB as Workbook
If Environ("COMPUTERNAME") = "janphi" Then

I tried to use the same concept for my code:

If Environ("COMPUTERNAME") = "Work_Laptop" Then
Else
InputForm1.Show
End If

but the InputForm1 still come up. I want InputForm1 to only load when
someone else opens the file but when I open the file from my computer, I
don't want it to open. That is what I am trying to accomplish.
Any ideas?




Jacob Skaria

Environ () Function
 
Ayo

Try the below in your immediate window and compare the name with what you
have given "Work_Laptop"

?Environ("COMPUTERNAME")

I would suggest to use Environ("USERNAME") .

If this post helps click Yes
---------------
Jacob Skaria


"Ayo" wrote:

Can someone explain to me how the Environ () works. I saw it been used in
another example code here as follows:

Private Sub Workbook_Open ()
Dim myB as Workbook
If Environ("COMPUTERNAME") = "janphi" Then

I tried to use the same concept for my code:

If Environ("COMPUTERNAME") = "Work_Laptop" Then
Else
InputForm1.Show
End If

but the InputForm1 still come up. I want InputForm1 to only load when
someone else opens the file but when I open the file from my computer, I
don't want it to open. That is what I am trying to accomplish.
Any ideas?




Patrick Molloy

Environ () Function
 
If Environ("USERNAME") < "janphi" Then
InputForm1.Show
End If


"Ayo" wrote in message
...
Can someone explain to me how the Environ () works. I saw it been used in
another example code here as follows:

Private Sub Workbook_Open ()
Dim myB as Workbook
If Environ("COMPUTERNAME") = "janphi" Then

I tried to use the same concept for my code:

If Environ("COMPUTERNAME") = "Work_Laptop" Then
Else
InputForm1.Show
End If

but the InputForm1 still come up. I want InputForm1 to only load when
someone else opens the file but when I open the file from my computer, I
don't want it to open. That is what I am trying to accomplish.
Any ideas?





All times are GMT +1. The time now is 09:05 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com