![]() |
Getting Host Name
Hi,
Does anyone know the VBA for getting the host name of a server (Windows Server 2003) that an Excel spreadsheet (Excel 2003) is sitting on (I don't mean path info, as I already know this and the host name doesn't show up). I'm trying to set-up a trigger, so that if an Excel file is removed from the server onto someones PC the file will behave differently. |
Getting Host Name
You could use this function to get the UNC from a file.
Pass the workbook path to the function, and just strip the UNC from the returned UNC path Function GetUNCPath(myDriveLetter As String) As String Dim lReturn As Long Dim szBuffer As String myDriveLetter = Left(myDriveLetter, 1) & ":" szBuffer = String$(256, vbNullChar) lReturn = WNetGetConnectionA(myDriveLetter, szBuffer, 256) If lReturn = 0 Then GetUNCPath = Left$(szBuffer, InStr(szBuffer, vbNullChar)) Else GetUNCPath = "Error" End If End Function -- HTH Bob Phillips (remove nothere from email address if mailing direct) "Delboy" wrote in message ... Hi, Does anyone know the VBA for getting the host name of a server (Windows Server 2003) that an Excel spreadsheet (Excel 2003) is sitting on (I don't mean path info, as I already know this and the host name doesn't show up). I'm trying to set-up a trigger, so that if an Excel file is removed from the server onto someones PC the file will behave differently. |
All times are GMT +1. The time now is 03:02 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com