Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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.


  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 2,510
Default 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.



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 10,593
Default 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.





  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default 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.




  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 857
Default 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.





  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 18
Default 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.





Reply
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Excel - Golf - how to display "-2" as "2 Under" or "4"as "+4" or "4 Over" in a calculation cell Steve Kay Excel Discussion (Misc queries) 2 August 8th 08 01:54 AM
Why can't I do a "basic search" of my computer in Excel 2007 Tom_in_New_Mexico New Users to Excel 0 May 15th 07 06:11 PM
Hashing function CryptAcquireContext Lib "advapi32" not working in new computer. Stephen Rasey[_3_] Excel Programming 5 December 25th 06 04:05 AM
clicking on "My Computer" does not find my Template just created Luis Excel Discussion (Misc queries) 0 June 9th 06 11:57 AM
"Hyperlinks can be harmfull to your computer and data...." how to shut this off marko Excel Discussion (Misc queries) 0 February 17th 06 12:27 PM


All times are GMT +1. The time now is 10:18 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"