Importing a sheet from a Excel Spreadsheet (1 Viewer)

dreamz

Is God Like
Local time
Today, 04:41
Joined
Dec 21, 2005
Messages
48
Hi

I'm trying to import a sheet from a excel spreadsheet.

this is my "code"

The problem is that when i hit the run button, it imports blank sheets or more likely is not importing at all :confused: :(

Code:
On Error GoTo ErrorTrap
    Dim dlgOpen2 As FileDialog
     Dim countrystring2 As String
    
    Set dlgOpen2 = Application.FileDialog(msoFileDialogFilePicker)

    With dlgOpen2
    
        
        If txtFile2 <> "" Then
            .InitialFileName = txtFile2
            countrystring2 = txtFile2 & "!RB_UPDATES"
        Else
            .InitialFileName = CurrentProject.Path
        End If
        .AllowMultiSelect = False
        .Show
    End With
    If dlgOpen2.SelectedItems.Count <> 0 Then
        txtFile2 = dlgOpen2.SelectedItems(1)
    End If
    Exit Sub
    
    DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9, "RB_UPDATES", countrystring2, True
    
ErrorTrap:
    MsgBox Err.Description, vbExclamation + vbOKOnly
End Sub
 

Users who are viewing this thread

Top Bottom