Results 1 to 4 of 4

auto open excel files in the folder

Threaded View

  1. #1
    Registered User
    Join Date
    09-16-2008
    Location
    malaysia
    Posts
    89

    auto open excel files in the folder

    hi all,

    i facing a problem here. i want to make the marco to let all the excel files in 1 folder auto open.
    below is the coding,
    i try many pc, all are function only 1 pc cannot find the application .file search and pop up an error. i attach the bug of print screen.

    can someome please help me, why some pc do not have any problem but only 1 pc has problem. i use same marco file. the microsoft office version is 2002. has something wrong with the coding or excel settings?

    please assist.

    Sub Get_Value_From_All()
        Dim lCount As Long
        Dim wbResults As Workbook
        Dim wbThis As Workbook
        Dim dblValue As Double
        Dim WbCnt  As Long
    
        With Application
            .ScreenUpdating = False
            .DisplayAlerts = False
            .EnableEvents = False
    
            On Error Resume Next
    
            Set wbThis = ThisWorkbook
            dblValue = 0
            WbCnt = 0
            With .FileSearch
                .NewSearch
                .LookIn = "C:\MyDocuments\TestResults" '<-Change path to suit
                .FileType = msoFileTypeExcelWorkbooks
    
                If .Execute > 0 Then    'Workbooks in folder
                    For lCount = 1 To .FoundFiles.Count    'Loop through all.
                        'Open Workbook x and Set a Workbook variable to it
                        Set wbResults = Workbooks.Open(Filename:=.FoundFiles(lCount), UpdateLinks:=0)
                      'your code here
                        End If
                        WbCnt = WbCnt + 1
                    Next lCount
            
            End With
    
            MsgBox "Checked " & WbCnt & " workbooks, total value is: " & dblValue
    
            On Error GoTo 0
            .ScreenUpdating = True
            .DisplayAlerts = True
            .EnableEvents = True
        End With
    End Sub
    Attached Files Attached Files

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1