LinkBack Thread Tools Search this Thread Display Modes
Prev Previous Post   Next Post Next
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 788
Default Error 424 - Object Requried

I have a form in MS Excel (Use the VB to create this form) on this form I have
a button that would allow me to browse and pick a file. Once I pick the file
I have another button that would let me import the file into the spread sheet
but I am get this Error 424 - object required.

Can someone help with this?
Code for Browse
Private Sub cmdBrowse_Click()
'Requires reference to Microsoft Office 11.0 Object Library.
Dim fDialog As Office.FileDialog
Dim varFile As Variant
Dim PicFn As String
'Clear listbox contents.
'Me.FileList.RowSource = ""

'Set up the File Dialog.
Set fDialog = Application.FileDialog(msoFileDialogFilePicker)
With fDialog
'Allow user to make multiple selections in dialog box
.AllowMultiSelect = False

'Set the title of the dialog box.
.Title = "Please select an Excel or a Text File"
.InitialView = msoFileDialogViewDetails
.ButtonName = "Select a File"
'.InitialFileName = CurrentProject.Path & "\pictures"
'Clear out the current filters, and add our own.
.Filters.Clear
.Filters.Add "Data File", "*.XLS; *.txt"
.Filters.Add "All Files", "*.*"

'Show the dialog box. If the .Show method returns True, the
'user picked at least one file. If the .Show method returns
'False, the user clicked Cancel.
If .Show = True Then
''Loop through each file selected and add it to our list box.
For Each varFile In .SelectedItems
txtInputFile.Value = Format$(varFile)
Next
Dim ExcelApp As Excel.Application
Set ExcelApp = CreateObject("Excel.Application")
ExcelApp.Workbooks.Open txtInputFile.Value
' ExcelApp.Sheets("Sheet1").PrintOut
ExcelApp.Workbooks.Close
Set ExcelApp = Nothing
End If
End With
End Sub
Code for import
'This would import the Current Month Data
Private Sub cmdImport_Click()
On Error GoTo ErrorCheck

varFilename = Me.txtInputFile
If IsNull(varFilename) Then
MsgBox "You must enter an input filename.", vbExclamation, " "
Me.txtInputFile.SetFocus
Exit Sub
End If


DoCmd.TransferText acImportDelim, , "Rate_Table_LIBOR_Swap ",
varFilename, True
Exit Sub

ErrorCheck:
Select Case Err.Number
Case 7874 'Import file not there to delete
Resume Next
Case Else
MsgBox "Error " & Err.Number & " - " & Err.Description
Exit Sub
End Select


'End Sub

Thanks in advance



 
Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules

Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On


Similar Threads
Thread Thread Starter Forum Replies Last Post
if query2- urgent requried deen Excel Worksheet Functions 1 January 16th 09 04:56 PM
Object Variable Not Set Error on Selection object Jean Excel Worksheet Functions 3 July 24th 06 06:45 PM
Error 1004, Application-definded or object-defined error Mirco Wilhelm[_2_] Excel Programming 9 January 7th 06 04:56 PM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Syntax Error Runtime Error '424' Object Required sjenks183 Excel Programming 1 January 23rd 04 09:25 AM


All times are GMT +1. The time now is 09:37 AM.

Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Copyright ©2004-2025 ExcelBanter.
The comments are property of their posters.
 

About Us

"It's about Microsoft Excel"