Computer Name

R

Rob Bovey

Hi Mark,

Here's one way to do it:

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


Sub GetMachineName()
Dim lLength As Long
Dim szNameBuffer As String
lLength = 255
szNameBuffer = String$(lLength, vbNullChar)
GetComputerNameA szNameBuffer, lLength
MsgBox Left$(szNameBuffer, lLength)
End Sub

--
Rob Bovey, MCSE, MCSD, Excel MVP
Application Professionals
http://www.appspro.com/

* Please post all replies to this newsgroup *
* I delete all unsolicited e-mail responses *
 
H

Harlan Grove

I need to know the name of the machine that the
spreadsheet is running on. So I can send the output to the
local printer.

Sending output to the default printer won't work?
 
B

Bob Kilmer

Environ("computername") returns the value of the environment variable
"computername."
 
Top