Home |
Search |
Today's Posts |
#1
Posted to microsoft.public.excel.programming
|
|||
|
|||
Get computer name
Is there a method to retreive the computer name?
|
#2
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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
Posted to microsoft.public.excel.programming
|
|||
|
|||
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 |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Row Height variations from computer to computer on same workbook | Excel Discussion (Misc queries) | |||
Formulaed cell response varies from computer to computer | Excel Discussion (Misc queries) | |||
Display size difference- PC computer vs. Mac computer? | Excel Discussion (Misc queries) | |||
How do I copy all Excel files from old computer to new computer? | Excel Discussion (Misc queries) | |||
Autocomplete works with my home computer but not the office computer | Excel Discussion (Misc queries) |