×
INTELLIGENT WORK FORUMS
FOR ENGINEERING PROFESSIONALS

Log In

Come Join Us!

Are you an
Engineering professional?
Join Eng-Tips Forums!
  • Talk With Other Members
  • Be Notified Of Responses
    To Your Posts
  • Keyword Search
  • One-Click Access To Your
    Favorite Forums
  • Automated Signatures
    On Your Posts
  • Best Of All, It's Free!
  • Students Click Here

*Eng-Tips's functionality depends on members receiving e-mail. By joining you are opting in to receive e-mail.

Posting Guidelines

Promoting, selling, recruiting, coursework and thesis posting is forbidden.

Students Click Here

Jobs

Get username of open file

Get username of open file

Get username of open file

(OP)
Hello all! I have a macro which will search for a PDF in a directory and kill it if it exists. A problem occurs if someone else has the file open. I would like to have a msgbox pop up with the username who has the file open on our network, so the user can go and ask them to close it. Is there a way to do this? Here is what I have so far:

If VBA.Dir(OldPDF) <> "" Then
    DelPDF = MsgBox("Delete the current PDF?", vbYesNo, "Question")
    If DelPDF = vbYes Then
        On Error Resume Next
            VBA.Kill (OldPDF)
            If Err.Number = 70 Then
                'MsgBox with username--how to find it?
            End If
    ElseIf DelPDF = vbNo Then
       MsgBox "<" & VBA.Dir(OldPDF) & "> retained. If not required, delete from directory."
    End If
End If

Thanks!!

Red Flag This Post

Please let us know here why this post is inappropriate. Reasons such as off-topic, duplicates, flames, illegal, vulgar, or students posting their homework.

Red Flag Submitted

Thank you for helping keep Eng-Tips Forums free from inappropriate posts.
The Eng-Tips staff will check this out and take appropriate action.

Reply To This Thread

Posting in the Eng-Tips forums is a member-only feature.

Click Here to join Eng-Tips and talk with other members!


Resources