LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 1
Default Ignore Error '1004' help


The following code allows me to insert multiple .xls files into my MSSQL
database. The problem I have is that when a file is not found the macro
stops with runtime error '1004' file not found. How or where can I fix
this. I have tried *On Error Resume Next* but then run into more
strange errors (think I am not adding in the right place). I would like
to just go to next file if it is unable to find file specified. I use a
Excel Add-in "ExcelSQL" which works great. Currently we have to have
all 120 files in place before the program can run, this is not always
possible for us.

Workbooks.Open Filename:="C:\2701.xls"
Range("A1").AddComment
Range("A1").Comment.Visible = False
Range("A1").Comment.Text Text:= _
"!SQL!GLAN:10,10 !ACTION!" & Chr(10) & "DELETE FROM sys_check
WHERE site_id = ('{A1}')" & Chr(10) & "INSERT INTO sys_check (site_id,
bad_pgs, good_pgs, sql_used, d_space, bu_size, bu_date, c_space,
client_count, bu_status)" & Chr(10) & "VALUES ('{A1}', '{A5}', '{A4}',
'{A7}', (LEFT(RIGHT('{A3}', 26),15)), (LEFT(RIGHT('{A6}', 32),15)),
(RIGHT('{A10}', 11)), (LEFT(RIGHT('{A2}', 26),15)), '{A8}',
(RIGHT(LEFT('{A9}', 8),1)))" & Chr(10) & "" _
, Start:=200
Range("A1").Select
Application.Run "ExecuteSelectedSQLStatements"
ActiveWindow.Close SaveChanges:=False


Workbooks.Open Filename:="C:\2301.xls"
Range("A1").AddComment
Range("A1").Comment.Visible = False
Range("A1").Comment.Text Text:= _
"!SQL!GLAN:10,10 !ACTION!" & Chr(10) & "DELETE FROM sys_check
WHERE site_id = ('{A1}')" & Chr(10) & "INSERT INTO sys_check (site_id,
bad_pgs, good_pgs, sql_used, d_space, bu_size, bu_date, c_space,
client_count, bu_status)" & Chr(10) & "VALUES ('{A1}', '{A5}', '{A4}',
'{A7}', (LEFT(RIGHT('{A3}', 26),15)), (LEFT(RIGHT('{A6}', 32),15)),
(RIGHT('{A10}', 11)), (LEFT(RIGHT('{A2}', 26),15)), '{A8}',
(RIGHT(LEFT('{A9}', 8),1)))" & Chr(10) & "" _
, Start:=200
Range("A1").Select
Application.Run "ExecuteSelectedSQLStatements"
ActiveWindow.Close SaveChanges:=False


Workbooks.Open Filename:="C:\1050.xls"
Range("A1").AddComment
Range("A1").Comment.Visible = False
Range("A1").Comment.Text Text:= _
"!SQL!GLAN:10,10 !ACTION!" & Chr(10) & "DELETE FROM sys_check
WHERE site_id = ('{A1}')" & Chr(10) & "INSERT INTO sys_check (site_id,
bad_pgs, good_pgs, sql_used, d_space, bu_size, bu_date, c_space,
client_count, bu_status)" & Chr(10) & "VALUES ('{A1}', '{A5}', '{A4}',
'{A7}', (LEFT(RIGHT('{A3}', 26),15)), (LEFT(RIGHT('{A6}', 32),15)),
(RIGHT('{A10}', 11)), (LEFT(RIGHT('{A2}', 26),15)), '{A8}',
(RIGHT(LEFT('{A9}', 8),1)))" & Chr(10) & "" _
, Start:=200
Range("A1").Select
Application.Run "ExecuteSelectedSQLStatements"
ActiveWindow.Close SaveChanges:=False

-Any help or suggestions will be appreciated and keep me sane.......


--
skito1
------------------------------------------------------------------------
skito1's Profile: http://www.excelforum.com/member.php...o&userid=36778
View this thread: http://www.excelforum.com/showthread...hreadid=564936

 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Excel 2003 Macro Error - Runtime error 1004 Cow Excel Discussion (Misc queries) 2 June 7th 05 01:40 PM
Ignore Error 1004 akyhne[_2_] Excel Programming 5 September 10th 04 06:29 AM


All times are GMT +1. The time now is 01:32 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"