ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Computer Name (https://www.excelbanter.com/excel-programming/298764-computer-name.html)

Mark Scholes

Computer Name
 
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


Rob Bovey

Computer Name
 
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 *


"Mark Scholes" wrote in message
...
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




Harlan Grove[_5_]

Computer Name
 
"Mark Scholes" wrote...
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?

--
To top-post is human, to bottom-post and snip is sublime.

Bob Kilmer[_2_]

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

"Mark Scholes" wrote in message
...
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





All times are GMT +1. The time now is 12:26 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com