Help!!!

tripps120

New member
Local time
Yesterday, 23:37
Joined
Jul 29, 2016
Messages
7
Private Sub cmd_mn01_c2_Click()
Dim sFile As String

sFile = dir("O:\OMD Library\Snow Route Sectoring\Snow Sectoring FY17\Manhattan FY17\MN01\MN01 Critical Routes\MN01 Critical 01 Rev *.xlsx")
If sFile <> "" Then
Workbooks.Open FileName:=sFile
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 get a runtime error 424 on the Workbooks.Open line Anyone have any ideas why??
 
you must instantiate the object, ie:
dim xlApp as Excel.Application
dim xlWB as Excel.Workbook

set xlApp = New Excel.Application
set xlWB = xlApp.WorkBooks.Open .....
 
Thanks arnelgp for the reply but I tried it and I get a compile error: User-defined type not defined and it highlights the line Dim xlWB as Excel.Workbook
 
Check your references in Tools -> References. You should have some version of the "Microsoft Excel xx.0 Object Library" checked, with the version number for your Office install in place of the x's. I'm guessing you don't, and if that's the case, find it in the list and check it.

If I'm right, that will fix your issue.
 

Users who are viewing this thread

Back
Top Bottom