Results 1 to 4 of 4

open file macro 2003 updating for 2007

Threaded View

randell.graybill open file macro 2003 updating... 08-12-2010, 08:21 PM
stanleydgromjr Re: open file macro 2003... 08-12-2010, 08:40 PM
randell.graybill Re: open file macro 2003... 08-12-2010, 09:16 PM
randell.graybill Re: open file macro 2003... 08-13-2010, 12:31 AM
  1. #1
    Forum Contributor
    Join Date
    04-03-2009
    Location
    USA, California
    MS-Off Ver
    Excel 2007
    Posts
    385

    open file macro 2003 updating for 2007

    Below is the code I currently have that opens all the files that end in .xls in the path. However this does not seem to work in excel 2007. Any suggestions on how to change this to work on 2007?

    
            With Application.FileSearch
                .NewSearch
                'Change path to suit
                .LookIn = "U:\Rotations\" & ZoneDate
                .FileType = msoFileTypeExcelWorkbooks
                'Optional filter with wildcard
                .FileName = "* Rotation.xls"
                    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)
                            wbExport = ActiveWorkbook.Name
    
    LR = Range("A" & Rows.Count).End(xlUp).Row
    Windows(wbExport).Activate
    LR = Range("A" & Rows.Count).End(xlUp).Row
    
    TryAgain:
    If Err.Number = 91 Then
    Err.Clear
    Cnt = Cnt + 1
    Workbooks("Master.xls").Sheets("Locations").Range("AA" & Cnt).Value = ActiveWorkbook.Sheets(1).Range("A3").Value
    GoTo ExitHere:
    End If
    
    If Err = 91 Then GoTo TryAgain
    
    Range("B3:B" & LR).find(What:="A", LookAt:=xlPart, SearchOrder:=xlByRows, SearchDirection:=xlNext, _
    MatchCase:=False, SearchFormat:=False).Activate
    
    If Err = 91 Then GoTo TryAgain
    
    Location = ActiveCell.Value
    ItemNumber = ActiveCell.Offset(, -1).Value
    
    Windows(MasterWB).Activate
    
    LR = Range("A" & Rows.Count).End(xlUp).Row
    With Range("A" & LR + 1)
    .Value = ItemNumber
    Calculate
    .Value = .Value
    End With
    
    With Range("B" & LR + 1)
    .Value = Location
    Calculate
    .Value = .Value
    End With
        
    ExitHere:
    Call unmerge
    
                            wbResults.Close savechanges:=False
                        Next lCount
                    End If
            End With
    Last edited by randell.graybill; 08-13-2010 at 12:32 AM.

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