![]() |
Computer "name"
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. |
Computer "name"
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. |
Computer "name"
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. |
Computer "name"
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. |
Computer "name"
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. |
Computer "name"
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. |
All times are GMT +1. The time now is 03:21 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com