Form output naming

C

Collings

I would like to build a form in Excel and code VB to write
the data to an output file. (which I feel confident that
I can do), but I would like to tie the output file name to
the computer name. By computer name I am referring to the
network computer ID, not the USER name from the office
application.

Is it possible to pull a computer's network name into VB?

This might be possible with HTML forms using CGI scripts,
but I don't know who to code CGI-BIN scripts.

TIA,
Collings
 
C

Chip Pearson

Collings,

You can get the computer name with the GetComputerName API
function. E.g.,


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

Function ComputerName() As String
Dim CN As String
Dim L As Long: L = 255
Dim Res As Long
CN = String$(L, " ")
Res = GetComputerName(CN, L)
ComputerName = Left(CN, L)
End Function


--
Cordially,
Chip Pearson
Microsoft MVP - Excel
Pearson Software Consulting, LLC
www.cpearson.com (e-mail address removed)
 

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

Top