Results 1 to 1 of 1

Issues after moving to Office 2010

Threaded View

  1. #1
    Registered User
    Join Date
    09-03-2008
    Location
    California
    Posts
    35

    Issues after moving to Office 2010

    I am getting error message when executing these statements after upgrading to Office 2010. This works perfectly fine in Office 2007.
    Can someone help me identify what's going on and how to fix this issues.
    I am trying to read data from an excel sheet into another excel file.
    I am attaching a screenshot of the error message I am getting.

    I am running Windows 7 Enterprise SP1 64 bit OS.
    Office Standard 2010 - 32bit.


    Private Sub GetData(ByVal SrcFile$)
       Dim SrcSheet$, SrcRange$
       Dim sTgt As String
       Dim rTgt As Range
       Dim fHdr As Boolean
    
       SrcSheet$ = "EXPORT DATA"
       SrcRange$ = "RAW_DATA"
       sTgt = Replace(ActiveCell.Address, "$", "")
       Set rTgt = ActiveSheet.Range(sTgt)
       fHdr = False
       
       Dim cn As ADODB.Connection
    
       Dim rs As ADODB.Recordset
       
    
       Dim a&
    
       Dim cnct$
    
       On Error GoTo err_GetData
    
    '  Initialize a variable for the connection string
    
        cnct$ = "DRIVER={Microsoft Excel Driver (*.xls, *.xlsx, *.xlsm, *.xlsb)};DBQ=" & SrcFile$
       Set cn = New ADODB.Connection
    
       
       With cn
    
          .Open cnct$
    
          Set rs = .Execute("SELECT * FROM [" & SrcRange$ & "]")
       End With
    
    '  Initialize a variable for the upper left cell of the target range
       Set rTgt = rTgt.Cells(1)
    
       With rs
    
       '  Determine whether to get the field header
          If fHdr Then
    
          '  Loop across the fields
             For a& = 0 To .Fields.Count - 1
    
             '  Get the field names
    
                rTgt.Offset(0, a&).Value = .Fields(a&).Name
    
             Next a&
    
          '  Advance the target pointer to the next available row in the
          '  destination worksheet
    
             Set rTgt = rTgt.Offset(1, 0)
    
          End If
    
       '  Apply the CopyFromRecordset method
    
          rTgt.CopyFromRecordset rs
    
       '  Close the RecordSet
          .Close
    
       End With
    
    '  Close the database connection
       cn.Close
    
    err_GetDataExit:
    
    '  Recover memory from object variables
    
       Set cn = Nothing
       Set rs = Nothing
    
    Exit Sub
    err_GetData:
    
    If Err.Number = -2147217842 Then GoTo err_GetDataExit
    'MsgBox "'Measurement Data' Workbook Must NOT Be Open", , "CHECK EXCEL WORKBOOKS:"
     MsgBox Err.Description, , Err.Number
    GoTo err_GetDataExit
    
    End Sub
    Attached Images Attached Images

Thread Information

Users Browsing this Thread

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

Similar Threads

  1. can't find project or library after moving to Office 2010
    By keithmorphett in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 07-16-2013, 10:26 AM
  2. Workbook VBA Project Reference will not migrate form Office 2010 to Office 2002
    By DAve Bradbury in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 05-06-2013, 07:43 AM
  3. [SOLVED] Sorting Macro From Office 2010 In Office 2003
    By splendidus in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 06-28-2012, 04:55 AM
  4. [SOLVED] Help! Switch from Office 2007 to Office 2010
    By Khristine L in forum Excel General
    Replies: 2
    Last Post: 05-28-2012, 08:37 AM
  5. Opening excel in office 2010 and not office "starter"
    By AlisonK in forum Excel General
    Replies: 3
    Last Post: 03-02-2012, 10:01 AM

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