![]() |
Open Excel file
I have a sub in Access that sucks data out of excel files based on a
path and filename in each record. If the path or filename are wrong and the Open statement not find the file I get a info message that says "c:\temp\filename.xls" can not be found. Check your spelling and try again." It has an ok button to dismiss it. How can I trap this "error" or result so I can just skip to the next record? It does not come up as an error so I can't handle it that way. Ideally I would like to keep track of which ones it cant find but that should be easy if I can figure out how to intersept the info message. Set xlsApp = CreateObject("Excel.application") Set wb = xlsApp.Workbooks.Open(Path & Filename, , True) |
Open Excel file
If Len(Dir(Path & Filename)) 0 Then
Set xlsApp = CreateObject("Excel.application") Set wb = xlsApp.Workbooks.Open(Path & Filename, , True) Else MsgBox Path & Filename & " does not exist." End If -- Doug Steele, Microsoft Access MVP http://I.Am/DougSteele (no e-mails, please!) "Michael" wrote in message ... I have a sub in Access that sucks data out of excel files based on a path and filename in each record. If the path or filename are wrong and the Open statement not find the file I get a info message that says "c:\temp\filename.xls" can not be found. Check your spelling and try again." It has an ok button to dismiss it. How can I trap this "error" or result so I can just skip to the next record? It does not come up as an error so I can't handle it that way. Ideally I would like to keep track of which ones it cant find but that should be easy if I can figure out how to intersept the info message. Set xlsApp = CreateObject("Excel.application") Set wb = xlsApp.Workbooks.Open(Path & Filename, , True) |
All times are GMT +1. The time now is 12:17 PM. |
Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com