error '424'

tripps120

New member
Local time
Today, 08:12
Joined
Jul 29, 2016
Messages
7
I am getting a run-time error '424' object required when I run the following code:
the line workbooks.open is where I am getting the error

Any help would gratefully appreciated!

Private Sub cmd_mn01_c1_Click()
Dim excelfile As String

excelfile = dir("\\FS125OMD02.dsnyad.nycnet\omd_data$\OMD Library\Snow Route Sectoring\Snow Sectoring FY17\Manhattan FY17\MN01\MN01 Critical Routes\MN01 Critical 01 Rev *.xlsx")
If excelfile <> "" Then
workbooks.Open FileName:=excelfile
Else
MsgBox "Can't Find File: O:\OMD Library\Snow Route Sectoring\Snow Sectoring FY17\Manhattan FY17\MN01\MN01 Critical Routes\MN01 Critical 01 Rev *.xlsx"
End If

End Sub
 
I'm pretty sure the code will barf on the * in the file name
 
Thanks Minty! Any way of opening the file using a wildcard bc the date after Rev usually changes. So to make sure I always have the up to date file I wanted to use a wildcard.
 
Maybe find the latest by file modified date?
Or store the revision number in a field and use a DMax to look that up and build the actual filename?
 
Minty I am kind of new to this whole coding thing....so would you be able to show me a sample code??
 

Users who are viewing this thread

Back
Top Bottom