Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Can Excel be programmed to test for my computer's name?
I'd like to create an If/Then statement by looking at the computer name the procedure is running on. User name won't work because it's the same user in both cases, just running the procedure on different machines. d.s. |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Environ() function gives you lots of these. I think that environ(5) is
computer name. Use different indexes and test the function regards, OssieMac "D.S." wrote: Can Excel be programmed to test for my computer's name? I'd like to create an If/Then statement by looking at the computer name the procedure is running on. User name won't work because it's the same user in both cases, just running the procedure on different machines. d.s. |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
It might be 5 on yours, but not on mine. Should always use the name not
index. -- HTH Bob (there's no email, no snail mail, but somewhere should be gmail in my addy) "OssieMac" wrote in message ... Environ() function gives you lots of these. I think that environ(5) is computer name. Use different indexes and test the function regards, OssieMac "D.S." wrote: Can Excel be programmed to test for my computer's name? I'd like to create an If/Then statement by looking at the computer name the procedure is running on. User name won't work because it's the same user in both cases, just running the procedure on different machines. d.s. |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
The index number for the Environ function will vary from one machine to
another, depending on the operating system and other installed software. You should never call Environ using an index number. Always use the name of the variable. Moreover, I have on rare occassion found that Environ("ComputerName") does not properly return the computer name. Therefore, I always use an API call, part of my standard library. Public Declare Function GetComputerName Lib "kernel32" Alias "GetComputerNameA" ( _ ByVal lpBuffer As String, _ nSize As Long) As Long Function ComputerName() As String Dim S As String Dim L As Long L = 256 S = String$(L, 0) GetComputerName S, L ComputerName = Left(S, L) End Function Sub Test() Dim CompName As String CompName = ComputerName() MsgBox "Computer Name: " & CompName End Sub -- Cordially, Chip Pearson Microsoft MVP - Excel Pearson Software Consulting www.cpearson.com (email on the web site) "OssieMac" wrote in message ... Environ() function gives you lots of these. I think that environ(5) is computer name. Use different indexes and test the function regards, OssieMac "D.S." wrote: Can Excel be programmed to test for my computer's name? I'd like to create an If/Then statement by looking at the computer name the procedure is running on. User name won't work because it's the same user in both cases, just running the procedure on different machines. d.s. |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
you can use:
environ("computername") -- Hope that helps. Vergel Adriano "D.S." wrote: Can Excel be programmed to test for my computer's name? I'd like to create an If/Then statement by looking at the computer name the procedure is running on. User name won't work because it's the same user in both cases, just running the procedure on different machines. d.s. |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Thanks, looks like that's going to work, at least it's working with the
Excel 2003 I'm running on this machine. (that's a new one for me, never noticed it before) d.s. "Vergel Adriano" wrote in message ... you can use: environ("computername") -- Hope that helps. Vergel Adriano "D.S." wrote: Can Excel be programmed to test for my computer's name? I'd like to create an If/Then statement by looking at the computer name the procedure is running on. User name won't work because it's the same user in both cases, just running the procedure on different machines. d.s. |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell | Excel Discussion (Misc queries) | |||
Why can't I do a "basic search" of my computer in Excel 2007 | New Users to Excel | |||
Hashing function CryptAcquireContext Lib "advapi32" not working in new computer. | Excel Programming | |||
clicking on "My Computer" does not find my Template just created | Excel Discussion (Misc queries) | |||
"Hyperlinks can be harmfull to your computer and data...." how to shut this off | Excel Discussion (Misc queries) |