Wrox Programmer Forums
Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
Old April 10th, 2005, 10:14 AM
Registered User
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts
Default Retrieve Computer Name Programatically

Is there anyone out there who can tell me how to retrieve the name of the computer in use programmatically using VBA?
Old April 10th, 2005, 12:25 PM
Friend of Wrox
Join Date: Nov 2004
Posts: 248
Thanks: 0
Thanked 1 Time in 1 Post

In a Windows environment the easiest way is:

  ComputerName = VBA.Environ("ComputerName")

If that doesn't give you what you want you can use an API:

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

Go to http://msdn.microsoft.com and search for "GetComputerName" for details about this.

Or you can use the Windows script host:

  Include a Reference to: "Window Script Host Object Model" (file C:\WINDOWS\system32\wshom.ocx) and do the following:

  Dim objSH As New IWshRuntimeLibrary.WshNetwork
  ComputerName = objSH.ComputerName

While Windows systems should all have the wshom.ocx file, adding this Reference can make your application vulnerable to having a "MISSING" reference.

Randall J Weers
Membership Vice President
Pacific NorthWest Access Developers Group
Old April 10th, 2005, 03:51 PM
Registered User
Join Date: Apr 2005
Posts: 4
Thanks: 0
Thanked 0 Times in 0 Posts

Worked Perfecly! Thanks A "Million" to Randall J Weers


Similar Threads
Thread Thread Starter Forum Replies Last Post
Accessing Programatically xlr8 BOOK: Beginning C# 2005 Databases 1 April 30th, 2007 08:56 AM
how to register Com components programatically vinaykumar_inavolu C# 2005 0 October 12th, 2006 07:19 AM
MaxDataAxisValue programatically ganans Crystal Reports 0 May 6th, 2006 06:30 PM
Using data programatically jasongorringe ASP.NET 2.0 Basics 1 February 10th, 2006 02:42 PM
How Do I Manipulate Graph Programatically sg48 Access VBA 11 June 24th, 2004 08:40 PM

Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.