Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 8
Default Get computer name

Is there a method to retreive the computer name?
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 7,247
Default Get computer name

Eric,

Try something like

Debug.Print Environ("Computername")



--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com


"Eric Marple" wrote in
message ...
Is there a method to retreive the computer name?



  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Get computer name

I use this in VBA within Access. It should also work in
Excel because it is using the Windows API

Function GetComputerName() As String
Dim lngLen As Long, lngX As Long
Dim strName As String

lngLen = 32
strName = String$(lngLen, 0)
lngX = apiGetComputerName(strName, lngLen)
If lngX < 0 Then
GetComputerName = Left$(strName, lngLen)
Else
GetComputerName = ""
End If

End Function

You also need the following in the declarations for the
module where the function exists.

Public Declare Function apiGetComputerName Lib "kernel32"
Alias _
"GetComputerNameA" (ByVal lpBuffer As String, nSize As
Long) As Long

Hope that helps!

Kevin

-----Original Message-----
Is there a method to retreive the computer name?
.

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 134
Default Get computer name

P.S. I have tested the code I just sent you in Excel and
it does work. I inserted the code into a Module for the
Workbook. I put the function header in the declarations. I
then called the function from a subroutine I run at
startup and inserted the value into a cell in my
spreadsheet and it works just fine.

Hope that helps!

Kevin
-----Original Message-----
Is there a method to retreive the computer name?
.

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
Row Height variations from computer to computer on same workbook Barb Reinhardt Excel Discussion (Misc queries) 1 April 20th 10 07:06 PM
Formulaed cell response varies from computer to computer WKH Excel Discussion (Misc queries) 3 November 21st 07 06:37 PM
Display size difference- PC computer vs. Mac computer? dk_ Excel Discussion (Misc queries) 1 October 17th 06 05:48 AM
How do I copy all Excel files from old computer to new computer? Rfarsh Excel Discussion (Misc queries) 2 December 20th 05 03:23 AM
Autocomplete works with my home computer but not the office computer Andy Excel Discussion (Misc queries) 4 December 11th 04 07:21 PM


All times are GMT +1. The time now is 10:11 PM.

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

About Us

"It's about Microsoft Excel"