LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #11   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 31
Default Computer Name with VBA

I am using Excel 2003.

Thank you.

Eric

"dkinn" wrote in message
...
Hi Eric

You didn't mention what version of Excel you were using but here is a 32
bit
version that works under most recent version, I haven't tried it under
2007
or Vista but it works under XP

Open a standard module and paste the following code

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

Sub Get_Computer_Name_Ex()
Dim Comp_Name_B As String * 25
'this function seems to work differntly than most, it doesn't return
the
number of char's placed in the buffer
Ret = GetComputerName(Comp_Name_B, Len(Comp_Name_B))
'but the string is always ended with a null terminated string so we can
use the Chr(0) function to find the end
Comp_Name = Left(Comp_Name_B, InStr(Comp_Name_B, Chr(0)))
'and return only the computer name
MsgBox Comp_Name
End Sub

hope this helps

David

"Eric" wrote:

Hello,

I would like my macro to check the name of the computer before running.
How can I retrieve the computer name value through a macro?


Thank you.


Eric





 
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


Similar Threads
Thread Thread Starter Forum Replies Last Post
Row Height variations from computer to computer on same workbook Barb Reinhardt Excel Discussion (Misc queries) 1 April 20th 10 07:06 PM
Formulaed cell response varies from computer to computer WKH Excel Discussion (Misc queries) 3 November 21st 07 06:37 PM
Display size difference- PC computer vs. Mac computer? dk_ Excel Discussion (Misc queries) 1 October 17th 06 05:48 AM
How do I copy all Excel files from old computer to new computer? Rfarsh Excel Discussion (Misc queries) 2 December 20th 05 03:23 AM
Autocomplete works with my home computer but not the office computer Andy Excel Discussion (Misc queries) 4 December 11th 04 07:21 PM


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