Home |
Search |
Today's Posts |
|
#1
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
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 |
#2
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Which line is highlighted when you get this error?
-- Regards, Tom Ogilvy "Chris" wrote: 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 |
#3
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Tom
No line is highlighted I am getting a pop up box with the error message. Also Tom, Can you help with the error I'm gettimg with my previous ? "Subject - Application to import and convert Data" I tryied your code but I am getting some erors still "Tom Ogilvy" wrote: Which line is highlighted when you get this error? -- Regards, Tom Ogilvy "Chris" wrote: 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 |
#4
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
If you hit the debug button in the popup, then you should be taken to the VBE
and see a line highlighted. -- Regards, Tom Ogilvy "Chris" wrote: Tom No line is highlighted I am getting a pop up box with the error message. Also Tom, Can you help with the error I'm gettimg with my previous ? "Subject - Application to import and convert Data" I tryied your code but I am getting some erors still "Tom Ogilvy" wrote: Which line is highlighted when you get this error? -- Regards, Tom Ogilvy "Chris" wrote: 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 |
#5
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
There is not debug button the pop up just has an ok button
"Tom Ogilvy" wrote: If you hit the debug button in the popup, then you should be taken to the VBE and see a line highlighted. -- Regards, Tom Ogilvy "Chris" wrote: Tom No line is highlighted I am getting a pop up box with the error message. Also Tom, Can you help with the error I'm gettimg with my previous ? "Subject - Application to import and convert Data" I tryied your code but I am getting some erors still "Tom Ogilvy" wrote: Which line is highlighted when you get this error? -- Regards, Tom Ogilvy "Chris" wrote: 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 |
#6
![]()
Posted to microsoft.public.excel.programming
|
|||
|
|||
![]()
Private Sub cmdImport_Click()
'On Error GoTo ErrorCheck 'comment out this line to see the real error Tim "Chris" wrote in message ... There is not debug button the pop up just has an ok button "Tom Ogilvy" wrote: If you hit the debug button in the popup, then you should be taken to the VBE and see a line highlighted. -- Regards, Tom Ogilvy "Chris" wrote: Tom No line is highlighted I am getting a pop up box with the error message. Also Tom, Can you help with the error I'm gettimg with my previous ? "Subject - Application to import and convert Data" I tryied your code but I am getting some erors still "Tom Ogilvy" wrote: Which line is highlighted when you get this error? -- Regards, Tom Ogilvy "Chris" wrote: 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 |
Reply |
Thread Tools | Search this Thread |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
if query2- urgent requried | Excel Worksheet Functions | |||
Object Variable Not Set Error on Selection object | Excel Worksheet Functions | |||
Error 1004, Application-definded or object-defined error | Excel Programming | |||
run-time error '1004': Application-defined or object-deifined error | Excel Programming | |||
Syntax Error Runtime Error '424' Object Required | Excel Programming |