+ Reply to Thread
Results 1 to 4 of 4

Excel 2007 not recognising code built in Excel 2003

Hybrid View

GNelson Excel 2007 not recognising... 02-23-2011, 07:56 AM
StephenR Re: Excel 2007 not... 02-23-2011, 08:29 AM
Marcol Re: Excel 2007 not... 02-23-2011, 09:39 AM
johnjohns Re: Excel 2007 not... 02-23-2011, 09:50 AM
  1. #1
    Registered User
    Join Date
    02-23-2011
    Location
    Glasgow
    MS-Off Ver
    Excel 2007
    Posts
    1

    Excel 2007 not recognising code built in Excel 2003

    Hi

    I recently upgraded my Excel from 2003 to 2007 and I am having issues running the below code through Visual Basic which imports data from a closed workbook in my directory to an open workbook. It was working fine in 2003 but since upgrading it seems to no longer recognise it. The problem seems to be when it is finding the file to import the data from and unsure how to fix it. Any help would be greatly appreciated:

    Option Explicit
    Dim strFileName As String
    Dim strCodeBook As String
    Dim wbCodeBook As Workbook
    
    Public Sub RunCodeOnAllXLSFiles()
    
    Dim lCount As Long
    Dim wbResults As Workbook
    
    
    Application.ScreenUpdating = False
    Application.DisplayAlerts = False
    Application.EnableEvents = False
    
    On Error Resume Next
    
    Set wbCodeBook = ThisWorkbook
    strCodeBook = wbCodeBook.Name
    
        With Application.FileSearch
        .NewSearch
             'Change path to suit
        .LookIn = "K:\BIG EUROPE ART\SALES\2011\RFP DATA\Cover Sheets"
        .FileType = msoFileTypeExcelWorkbooks
            '.Filename = "Book*.xlsx"
            
        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)
                                      
        strFileName = wbResults.Name
                                                       
        Call ImportData
                     
        wbResults.Close SaveChanges:=True
                 
        Next lCount
        End If
        End With
        
        On Error GoTo 0
        Application.ScreenUpdating = True
        Application.DisplayAlerts = True
        Application.EnableEvents = True
    End Sub
    
    Sub ImportData()
    
    ''written by rmcniven,maplecourt
    
    ''declare variables for data to import
    Dim strAccount As String
    Dim strAcManager As String
    Dim dtDeadline As Date
    Dim dtReceived As Date
    Dim strSpecial As String
    Dim strLRA As String
    Dim strCommissionable As String
    Dim strCXL As String
    Dim strSTDRoomsOnly As String
    Dim strAllowSquatters As String
    Dim strNumberProperties As String
    Dim str3rdPartysite As String
    Dim strsite As String
    Dim a As Integer
    
    ''assign data in cover sheet to variables
    
    Windows(strFileName).Activate
    
    With Sheets("RFPC Instruction Page")
        strAccount = .Cells(5, 4).Value
        strAcManager = .Cells(3, 4).Value
        dtDeadline = .Cells(9, 4).Value
        dtReceived = .Cells(3, 11).Value
        strSpecial = .Cells(65, 3).Value
        strLRA = .Cells(13, 4).Value
        strCXL = .Cells(14, 4).Value
        strCommissionable = .Cells(15, 4).Value
        strSTDRoomsOnly = .Cells(16, 4).Value
        strAllowSquatters = .Cells(60, 4).Value
        strNumberProperties = .Cells(11, 4).Value
        str3rdPartysite = .Cells(33, 8).Value
        strsite = .Cells(36, 8).Value
        
        
    End With
    
    ''dump data into corresponding cells in consolidation workbook(this one)
    
    wbCodeBook.Activate
    
    Cells(3, 1).Select
    
    For a = 1 To 10000
        If Cells(3 + (a - 1), 1).Value = "" Then
        Exit For
        End If
    Next a
    
    Cells(3 + (a - 1), 1).Value = strAccount
    Cells(3 + (a - 1), 2).Value = strAcManager
    Cells(3 + (a - 1), 4).Value = dtDeadline
    Cells(3 + (a - 1), 5).Value = dtReceived
    Cells(3 + (a - 1), 7).Value = strSpecial
    Cells(3 + (a - 1), 9).Value = strLRA
    Cells(3 + (a - 1), 10).Value = strCommissionable
    Cells(3 + (a - 1), 11).Value = strCXL
    Cells(3 + (a - 1), 12).Value = strSTDRoomsOnly
    Cells(3 + (a - 1), 15).Value = strAllowSquatters
    Cells(3 + (a - 1), 16).Value = strNumberProperties
    Cells(3 + (a - 1), 17).Value = str3rdPartysite
    Cells(3 + (a - 1), 18).Value = strsite
    
    
    End Sub
    Last edited by davesexcel; 02-23-2011 at 08:01 AM.

  2. #2
    Forum Guru
    Join Date
    08-26-2007
    Location
    London
    Posts
    4,606

    Re: Excel 2007 not recognising code built in Excel 2003

    My recollection is that FileSearch doesn't exist in 2007. If you Google you should find an alternative or somebody here will put you on the right track.

  3. #3
    Forum Guru (RIP) Marcol's Avatar
    Join Date
    12-23-2009
    Location
    Fife, Scotland
    MS-Off Ver
    Excel '97 & 2003/7
    Posts
    7,216

    Re: Excel 2007 not recognising code built in Excel 2003

    Correct Stephen, FileSearch was removed from 2007 and this seems to be a very touchy point with many people.

    GNelson
    Have a look at this thread in this forum.
    http://www.excelforum.com/excel-prog...el-2007-a.html
    If you need any more information, please feel free to ask.

    However,If this takes care of your needs, please select Thread Tools from menu above and set this topic to SOLVED. It helps everybody! ....

    Also
    اس کی مدد کرتا ہے اگر
    شکریہ کہنے کے لئے سٹار کلک کریں
    If you are satisfied by any members response to your problem please consider using the small Star icon bottom left of their post to show your appreciation.

  4. #4
    Forum Contributor johnjohns's Avatar
    Join Date
    11-19-2007
    Location
    Dubai, UAE
    MS-Off Ver
    2003 and 2007
    Posts
    526

    Re: Excel 2007 not recognising code built in Excel 2003

    This question has been asked in this forum by so many people, including me. Here are the answers I got
    https://www.excelforum.com/showthread.php?t=711455

    Sorry. Marcol has given the same link!!
    Last edited by johnjohns; 02-23-2011 at 09:53 AM.
    regards

    johnjohns

    When you are not sure where to go, every road takes you there!

+ Reply to Thread

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