Results 1 to 18 of 18

Thread: [RESOLVED] VBA to VBScript

Threaded View

  1. #1

    Thread Starter
    Lively Member
    Join Date
    Jan 2008
    Posts
    106

    Resolved [RESOLVED] VBA to VBScript

    I've been trying to develop a File distribution script, with some success, I've managed to get the script to copy one file and then distribute it into the many folders, but now I'd like it to record the folders it has skipped due to errors IE: Error 76 "File path not found". But I can't get it to work, Any suggestions?
    Code:
    Workbooks.Add
    Range("A1").Value = "Folders Omitted"
    Range("A1").Font.Bold = True
    ActiveCell.Offset(1, 0).Select
    
    Dim fso, f, fc, f1, SourceFile
    Set fso = CreateObject("Scripting.FileSystemObject")
    Set SourceFile = fso.GetFile("E:\Test Area\NormalUpdates\NormalPM\normal.dot")
    Set f = fso.Getfolder("E:\Test Area\")
    Set fc = f.SubFolders
    For Each f1 In fc
    
    If InStr(f1.Name, ",") > 0 Then
    On Error Resume Next
    SourceFile.Copy f1 & "\Databases\normal_PM\"
    If Err.Number <> 0 Then
    Select Case Err.Number ' Evaluate error number.
    Case 76 ' "Path not found" error.
    ActiveCell.Value = f1
    ActiveCell.Offset(1, 0).Select
    'LogInformation f1
    Err.Clear
    Case Else
    ActiveCell.Value = f1
    ActiveCell.Offset(1, 0).Select
    End Select
    Else
    End If
    On Error GoTo 0
    End If
    Next
    
    Objexcel.ActiveWorkbook.SaveAs("E:\Test Area\Noticeboard\NormalUpdates\omitted files.xls")
    ObjWorkbook.Close
    Last edited by Hack; Jan 23rd, 2008 at 07:14 AM. Reason: Added Code Tags

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width