LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default computer_name


Hello Simplefi,

Not that I am aware of. The only method I have seen and used is a use
defined function that calls the Windows API. It is quite easy t
install and use. Here are the code and the directions to install th
API call and user defined function.

Installation Directions...
1) Copy the code in this post using CTRL+C
2) Open the Workbook the macro will be installed in.
3) Press ALT+F11 to launch the VBA Editor.
4) Press ALT+I to activate the Insert Menu
5) Press M to insert a new VBA module into the Workbook.
6) Press CTRL+V to paste the macro code into the module.
7) Press CTRL+S to save the Workbook changes

Using the Macro...
Simply use the Formula below in a cell to return the computr's name.

=ComputerName()


Code
-------------------

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

Function ComputerName() As String

Dim CompName As String * 256
Dim RetVal

CompName = String(0, 256)
RetVal = GetComputerName(CompName, 256)
Chars = InStr(1, CompName, Chr$(0)) - 1

If Chars 0 Then
ComputerName = Left(CompName, Chars)
Else
ComputerName = ""
End If

End Function

-------------------


Sincerely,
Leith Ros

--
Leith Ros
-----------------------------------------------------------------------
Leith Ross's Profile: http://www.excelforum.com/member.php...fo&userid=1846
View this thread: http://www.excelforum.com/showthread.php?threadid=55344



 
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



All times are GMT +1. The time now is 08:21 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"