Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Run-time error '1004'

I'm running Windows 2000 and Excel 2003.
When I run the code below, I get a "Run-time eorr '1004': Method 'Open' of
object 'Workbooks' failed" error.
Can someone tell me why?
TIA

Sub Macro()
Workbooks.Open Filename:= _
"C:\downloads\GPF_PY.xls"
End Sub



--
Ken Hudson
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 35,218
Default Run-time error '1004'

I'd guess that the file didn't exist.

Typing error in the folder/filename????

Ken Hudson wrote:

I'm running Windows 2000 and Excel 2003.
When I run the code below, I get a "Run-time eorr '1004': Method 'Open' of
object 'Workbooks' failed" error.
Can someone tell me why?
TIA

Sub Macro()
Workbooks.Open Filename:= _
"C:\downloads\GPF_PY.xls"
End Sub

--
Ken Hudson


--

Dave Peterson
  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 186
Default Run-time error '1004'

Thanks for the reply. This was really puzzling to me.
The initial file was saved as a CSV file and then opened in Excel and saved
as an Excel file. It did exist as an Excel file.
The problem was that, when it was saved as a CSV file, its worksheet brought
the default name ".csv)GENSOFMO(2)" with it. I saved the file in Excel with
that worksheet name. I can open the workbook "manually", but got the error
when trying to use VB.
I renamed the worksheet and life is good again.
--
Ken Hudson


"Dave Peterson" wrote:

I'd guess that the file didn't exist.

Typing error in the folder/filename????

Ken Hudson wrote:

I'm running Windows 2000 and Excel 2003.
When I run the code below, I get a "Run-time eorr '1004': Method 'Open' of
object 'Workbooks' failed" error.
Can someone tell me why?
TIA

Sub Macro()
Workbooks.Open Filename:= _
"C:\downloads\GPF_PY.xls"
End Sub

--
Ken Hudson


--

Dave Peterson

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 14
Default Run-time error '1004'

Hi Ken

This script will allow you to select the file you wish to open, if the format
you want ins't csv then change it to desired format

Application.DisplayAlerts = False
Application.ScreenUpdating = False

fileToOpen = Application _
.GetOpenFilename("Comma Delimited (*.csv), *.csv")
If fileToOpen < False Then
TextBox2.Value = "Opening " & fileToOpen
Else
Exit Sub
End If

Workbooks.OpenText Filename:="" & fileToOpen
DoEvents

--
Message posted via http://www.officekb.com
Reply
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
Run time error 1004, General ODBC error [email protected] New Users to Excel 0 September 19th 05 01:41 AM
run-time error '1004': Application-defined or object-deifined error [email protected] Excel Programming 5 August 10th 05 09:39 PM
Run time error '1004': Generaol ODBC error Dwaine Horton[_3_] Excel Programming 2 April 26th 05 02:52 PM
Run time error 1004 General ODCB Error Kevin Excel Programming 3 February 26th 05 12:51 PM
Application Run Time Error 1004 and Stack Error ExcelMonkey[_190_] Excel Programming 9 February 11th 05 04:48 PM


All times are GMT +1. The time now is 07:52 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"