Consulting

Results 1 to 2 of 2

Thread: process array of excel files not working

  1. #1

    process array of excel files not working

    hi, I have some VBA code that I use to process an array of CSV files. I originally got this code from “Mastering Excel 2003”. It worked fine for about a year (with xp) then suddenly it has started to work only intermittently. Now it hardly works at all.

    INFO
    Version – I've tried using on xp and also on vista – generally doesn't work at all anymore on xp but occasionally works on vista (usually after shutdown and restart)
    What I want it to do – get the function “GetEXcelFiles” to recognize that I've selected an array of CSV files so I can process them in the main part of my script
    Problem – most of the time the function “GetExcelFiles” fails to recognise that I've selected an array of CSV files and the sub exits ie the multiselect part of this function doesn't seem to work consistently

    Can anyone help?????


    CODE

    [VBA]Sub ProcessANZFileBatch()
    Dim nIndex As Integer
    Dim vFiles As Variant
    Dim wb As Workbook
    Dim wsname As String
    Dim adr1 As String
    Dim bAlreadyOpen As Boolean
    Dim ws As Worksheet

    vFiles = GetExcelFiles("Select Workbooks for Processing")

    ' Make sure the dialog wasn't cancelled - in which case vFiles would equal False and therefore wouldn't be an array.
    If Not IsArray(vFiles) Then
    Debug.Print "No files selected."
    Exit Sub
    End If

    ' OK - loop through the filenames

    For nIndex = 1 To UBound(vFiles)
    Code to process each file goes here …….



    Function GetExcelFiles(sTitle As String) As Variant
    GetExcelFiles = Application.GetOpenFilename(Title:=sTitle, MultiSelect:=True)
    End Function[/VBA]

  2. #2
    VBAX Wizard lucas's Avatar
    Joined
    Jun 2004
    Location
    Tulsa, Oklahoma
    Posts
    7,323
    Location
    Steve
    "Nearly all men can stand adversity, but if you want to test a man's character, give him power."
    -Abraham Lincoln

Posting Permissions

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