Forum Discussion
Run-time error '-2147024894 (80070002)' Single Macros won't work on my laptop but works for others.
Hi
I have Excel 365 W10 HP laptop. I have an excel file with lots of Macros in it. One single macros will not work, the error is Run-time error '-2147024894 (80070002)' Automation error. The system cannot find the file specified. The macros has been tried by multiple people including a different laptop I own and it works perfectly. The debug stops on this line of code
myShell.Run FolderName & FileName
The code it to double click on a listbox in a userform to open jpg and pdf files which are in the same folder as the excel file. The entire code for the macros is
Private Sub lstDatabase_DblClick(ByVal Cancel As MSForms.ReturnBoolean)
Dim FolderName As String, FileName As String
Dim myShell As WshShell
'change folder path to database if required
FolderName = ThisWorkbook.Path & "\"
FileName = Me.lstDatabase.Value
'On Error GoTo myerror
If Not Dir(FolderName & FileName, vbNormal) = vbNullString Then
Set myShell = New WshShell
myShell.Run FolderName & FileName
Else
Err.Raise 53
End If
'report errors
myerror:
If Err <> 0 Then MsgBox (Error(Err)), 48, "Error"
Set myShell = Nothing
End Sub
Any help is appreciated.
8 Replies
- JKPieterseSilver ContributorWhat does Dir(FolderName & FileName) return?
- DellehurleyCopper Contributor
JKPieterse Hi Jan, I am not 100% certain what you mean.
If I watch FolderName & FileName I get the correct path to the document.
eg. Watch : : FolderName & Filename : "C:\Users\delle\Dropbox\Genealogy\Family Tree\FMa4216.pdf" : String : FrmForm.lstDatabase_DblClick
If you meant for me to edit to macros to Dir(FolderName & FileName) it comes back as only the file name.
eg. Watch : : Dir(FolderName & Filename) : "FMa4216.pdf" : String : FrmForm.lstDatabase_DblClick
If I have misunderstood please let me know.
D
- JKPieterseSilver ContributorOn which line of the code does the error occur precisely? (which line is yellow when you click Debug)?