Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 49
Default run time error 1004 in loop

Please help
Thanks

Sub Macro1()
' On each stick memory, I will have a book named as 'IDnumber.xls'
' I'm attempting to identify which drive that has 'IDtestnumber.xls'
' This script supposed to do that, but I kept getting 'Run-time error 1004'
' Memory stick keeps changing drive letter. Is there a way to identify them?
' If they have ID No., how do I find out the drive letter associated with
that ID No.?
Dim i As Long
Dim drive, driveletter As String
Application.ScreenUpdating = False
For i = 1 To 16
drive = Application.Choose(i, "E:", "F:", "G:", "H:", "I:", "J:")
On Error GoTo skip1
Workbooks.Open Filename:=drive & "\IDtestnumber.xls", UpdateLinks:=0
' If Error = Error(1004) Then GoTo skip1
Workbooks("IDtest.xls").Close SaveChanges:=False
GoTo skip2
skip1:
Next i
skip2:
driveletter = drive
End Sub
  #2   Report Post  
Posted to microsoft.public.excel.misc
external usenet poster
 
Posts: 35,218
Default run time error 1004 in loop

Check your other post.

danpt wrote:

Please help
Thanks

Sub Macro1()
' On each stick memory, I will have a book named as 'IDnumber.xls'
' I'm attempting to identify which drive that has 'IDtestnumber.xls'
' This script supposed to do that, but I kept getting 'Run-time error 1004'
' Memory stick keeps changing drive letter. Is there a way to identify them?
' If they have ID No., how do I find out the drive letter associated with
that ID No.?
Dim i As Long
Dim drive, driveletter As String
Application.ScreenUpdating = False
For i = 1 To 16
drive = Application.Choose(i, "E:", "F:", "G:", "H:", "I:", "J:")
On Error GoTo skip1
Workbooks.Open Filename:=drive & "\IDtestnumber.xls", UpdateLinks:=0
' If Error = Error(1004) Then GoTo skip1
Workbooks("IDtest.xls").Close SaveChanges:=False
GoTo skip2
skip1:
Next i
skip2:
driveletter = drive
End Sub


--

Dave Peterson
Reply
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
run time error 1004 Louise Excel Discussion (Misc queries) 1 January 18th 07 11:11 PM
run time error 1004 Louise Excel Worksheet Functions 0 January 18th 07 08:16 PM
Run Time error 1004 Steph Excel Discussion (Misc queries) 1 May 4th 06 10:29 PM
Run time error 1004 cinvic Excel Discussion (Misc queries) 3 February 19th 06 12:27 AM
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM


All times are GMT +1. The time now is 11:17 PM.

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"