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

I use the piece of code below in 3 macros in three different workbooks to
open files. In one of the macros it will not work. I get the following
error:
run time error '1004'
pobcinv.xls could not be found.....

It's looking for my filename with an xls entension. Can it I make it not
look for the file name with an extension. It must be something unique to
this one workbook since this is the only one that errors. If there is a
solution I'll add it to the othere macro's.

Thanks


Sub Open_File()

Workbooks.OpenText Filename:= _
"\\123.456.78.9\windows\inventory\DailyPackingList s\Vendor1\pobcinv" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:= _
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1, 1),
_
TrailingMinusNumbers:=True



  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 27,285
Default run time error '1004'

Perhaps something like:

Sub Open_File()
Dim sPath as String, sName as String, sFile as String

sPath = "\\123.456.78.9\windows\inventory\DailyPackingList s\Vendor1\"
sName = "pobcinv"

sFile = Dir(sPath & sName & ".*")
if sFile < "" then

Workbooks.OpenText Filename:= _
spath & sFile, _
Origin:=437, StartRow:=1, _
DataType:=xlDelimited, _
TextQualifier:=xlDoubleQuote, _
ConsecutiveDelimiter:=False, _
Tab:=False, _
Semicolon:=False, _
Comma:=False, _
Space:=False, _
Other:=False, FieldInfo:=Array(1, 1), _
TrailingMinusNumbers:=True


--
Regards,
Tom Ogilvy


"Grant" wrote in message
...
I use the piece of code below in 3 macros in three different workbooks to
open files. In one of the macros it will not work. I get the following
error:
run time error '1004'
pobcinv.xls could not be found.....

It's looking for my filename with an xls entension. Can it I make it not
look for the file name with an extension. It must be something unique to
this one workbook since this is the only one that errors. If there is a
solution I'll add it to the othere macro's.

Thanks


Sub Open_File()

Workbooks.OpenText Filename:= _
"\\123.456.78.9\windows\inventory\DailyPackingList s\Vendor1\pobcinv" _
, Origin:=437, StartRow:=1, DataType:=xlDelimited, TextQualifier:=

_
xlDoubleQuote, ConsecutiveDelimiter:=False, Tab:=False,
Semicolon:=False _
, Comma:=False, Space:=False, Other:=False, FieldInfo:=Array(1,

1),
_
TrailingMinusNumbers:=True





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 Robert[_16_] Excel Programming 1 August 13th 04 07:30 PM
Run time error '1004' Ikan[_2_] Excel Programming 0 October 29th 03 09:36 PM
Run time error 1004 Paul B[_6_] Excel Programming 3 October 26th 03 02:14 PM


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