How to return the machine name?
On Fri, 27 Apr 2012 11:15:39 -0700 (PDT), Maury Markowitz wrote:
Hey everyone,
I'm back into VBA programming after a long hiatus, and this time I'm
on the Mac just to make things confusing and difficult to debug :-)
My current problem is a simple one: we have a DB on a virtual server
and I'd like the VBA to only run when opened on that machine (via
RDP). Google fails to reveal an easy way to test if I'm running on a
particular machine - is there one?
In VBA on the PC, you can get that by a call to the kernel32.dll I don't know what the equivalent would be on the Mac, though.
====================
Option Explicit
Private Declare Function GetComputerName Lib "kernel32.dll" _
Alias "GetComputerNameA" (ByVal lpBuffer As String, ByRef nSize As Long) As Long
Sub GetName()
Dim lpBuff As String * 1313
GetComputerName lpBuff, Len(lpBuff)
Debug.Print lpBuff
End Sub
===========================
|