PDA

View Full Version : Solved: getting the file not found error



sleepy_think
05-29-2008, 12:08 PM
Hey everyone,

I put my last thread as solved so i can do this one abit differently (with a dummy work book) :)

(before you run anything make a test2 dir in your c:\ )


The error I get happens when the cell range is a blank, does anyone know the solution for this one?

Bob Phillips
05-29-2008, 12:20 PM
Sub InputFiles()
' Then input information needed and save as userid(filemname)
' Finally copy to the old input folder

'first file - RESETPWD.csv

Dim Filename As String
Dim aduserid As String
Dim secgroup As String
Dim Resname As String
Dim WS As Worksheet
Dim OutputFile As String

destinationpath = "c:\test2\"
Set WS = Worksheets("sheet1")

For Each cell In WS.Range("A2:A50")

If cell.Value <> "" Then

aduserid = cell.Value
Resname = cell.Offset(0, 1).Value
Filename = destinationpath & Resname
OutputFile = Filename

If Len(Dir(OutputFile)) Then
Kill OutputFile
End If

Open Filename For Output As #1
Write #1, "blah blah blah"
Close #1
End If
Next cell
End Sub

sai_golden
05-29-2008, 12:23 PM
Hi,

Please find attached the revised code. Added a if condition after the for statement.

I hope this should work:hi:

sleepy_think
05-29-2008, 12:46 PM
Thanks! its seems to have worked (no errors)