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!!
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!!