ChrisAch
08-19-2016, 06:51 AM
Hi all
I have been using the below code for a few months, and always worked fine for me.
All of a sudden it now gives me run time error 91 - 'object variable or with block variable not set'
Sub Open_latest_file()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'Open the latest Extract file.
sn = Array("\\NetworkExample.All\ (file://\\NetworkExample.All\)", "\\NetworkExample.All\ (file://\\NetworkExample.All\)", "") ' source directory / destination directory
sn(2) = sn(0) & Split(CreateObject("wscript.shell").exec("cmd /c dir """ & sn(0) & "*.zip"" /b/o-d").StdOut.ReadAll, vbCrLf)(0)
With CreateObject("Shell.Application")
.Namespace(sn(1)).CopyHere .Namespace(sn(2)).Items.Item(0)
sn(2) = sn(1) & .Namespace(sn(2)).Items.Item(0)
End With
Workbooks.Open sn(2)
Can anyone see any problems with the above that would cause error 91?
Thank you
I have been using the below code for a few months, and always worked fine for me.
All of a sudden it now gives me run time error 91 - 'object variable or with block variable not set'
Sub Open_latest_file()
Application.DisplayAlerts = False
Application.ScreenUpdating = False
'Open the latest Extract file.
sn = Array("\\NetworkExample.All\ (file://\\NetworkExample.All\)", "\\NetworkExample.All\ (file://\\NetworkExample.All\)", "") ' source directory / destination directory
sn(2) = sn(0) & Split(CreateObject("wscript.shell").exec("cmd /c dir """ & sn(0) & "*.zip"" /b/o-d").StdOut.ReadAll, vbCrLf)(0)
With CreateObject("Shell.Application")
.Namespace(sn(1)).CopyHere .Namespace(sn(2)).Items.Item(0)
sn(2) = sn(1) & .Namespace(sn(2)).Items.Item(0)
End With
Workbooks.Open sn(2)
Can anyone see any problems with the above that would cause error 91?
Thank you