Nov 19 2020 09:05 PM
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.
Nov 20 2020 08:08 AM
Nov 22 2020 09:41 PM
@Jan Karel Pieterse 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
Nov 23 2020 02:42 AM
Nov 24 2020 01:58 AM
@Jan Karel Pieterse the error is with this line
myShell.Run FolderName & FileName
Nov 24 2020 02:11 AM
Nov 24 2020 03:51 PM
@Jan Karel Pieterse I think you are correct with the error being with my machine and shell, hopefully there is a way to fix it. If I place a hyperlink in the database and click on it (jpg or pdf) it opens perfectly. as do all the files open via file explorer too.
Dec 02 2020 02:45 PM
Hi Jan, Do you think my issue would be resolved if I restored factory reset my laptop?
Dannielle
Dec 03 2020 01:16 AM