Computer Name

  • Thread starter Thread starter Mark Scholes
  • Start date Start date
M

Mark Scholes

Hi,
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.

Thanks MarkS
(e-mail address removed)
 
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 *
 
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?
 
Environ("computername") returns the value of the environment variable
"computername."
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top