ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   'On Error' question (https://www.excelbanter.com/excel-programming/333194-error-question.html)

geb

'On Error' question
 
I have a macro that imports external data specifying a file name, location.

With ActiveSheet.QueryTables.Add(Connection.....
......End With

If that file is not there I would want a message box.
I have tried 'On Error' but it behaved the same with
or without the file present.
Where do I need to do the display a message if the file is missing
and not display a message if the file is found?


(Same question asked yesterday after I tried the 'On Error')

bac

'On Error' question
 
try:

If <file path\name then 'Will be TRUE if file exists, FALSE if not

import file

else
do msg box

end if

"GEB" wrote:

I have a macro that imports external data specifying a file name, location.

With ActiveSheet.QueryTables.Add(Connection.....
.....End With

If that file is not there I would want a message box.
I have tried 'On Error' but it behaved the same with
or without the file present.
Where do I need to do the display a message if the file is missing
and not display a message if the file is found?


(Same question asked yesterday after I tried the 'On Error')



All times are GMT +1. The time now is 07:37 PM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
ExcelBanter.com