web development India freelance website designer
Function fWhoHasDocFileOpen(ByVal strDocFile As String) As String

'************************************************************
'Purpose: Returns the network name of the user who has trDocFile open
'Inputs: strDocFile - Complete path to the Word document
'Output: Name of the user if successful, else no output
'*************************************************************

On Error GoTo ErrHandler
Dim intFree As Integer
Dim intPos As Integer
Dim strDoc As String
Dim strFile As String
Dim strExt As String
Dim strUserName As String

intFree = FreeFile()
strDoc = DiR(strDocFile)
intPos = InStr(1, strDoc, ".")

If intPos > 0 Then
strFile = Left$(strDoc, intPos - 1)
strExt = Right$(strDoc, Len(strDoc) - intPos)
End If

intPos = 0

If Len(strFile) > 6 Then
If Len(strFile) = 7 Then
strDocFile = fFileDirPath(strDocFile) & "~$" & _
Mid$(strFile, 2, Len(strFile)) & "." & strExt
Else
strDocFile = fFileDirPath(strDocFile) & "~$" & _
Mid$(strFile, 3, Len(strFile)) & "." & strExt
End If
Else
strDocFile = fFileDirPath(strDocFile) & "~$" & DiR(strDocFile)
End If

Open strDocFile For Input Shared As #intFree
Line Input #intFree, strUserName
strUserName = Right$(strUserName, Len(strUserName) - 1)
fWhoHasDocFileOpen = strUserName

ExitHere:
'on error resume next
Close #intFree
Exit Function

ErrHandler:
fWhoHasDocFileOpen = "Not present, or is not opened by another user..."
Resume ExitHere
End Function

Private Function fFileDirPath(strFile As String) As String
Dim strPath As String
strPath = DiR(strFile)
fFileDirPath = Left(strFile, Len(strFile) - Len(strPath))
End Function

Public Sub gsExample()
MsgBox fWhoHasDocFileOpen("c:\readme.doc")
End Sub
Who opened your Word document

1651 1652 1653 1654 1655 1656 1657 1658 1659 1660 1661 1662 1663 1664 1665 1666 1667 1668 1669 1670 1671 1672 1673 1674 1675 1676 1677 1678 1679 1680 1681 1682 1683 1684 1685 1686 1687 1688 1689 1690 1691 1692 1693 1694 1695 1696 1697 1698 1699 1700

Freelance ASP PHP web development | Web developer India Web development India| Prayagasoft - web designer India, Ecommerce developer india, Ecommerce design