PC Review


Reply
Thread Tools Rate Thread

Cannot obtain Filename

 
 
=?Utf-8?B?R3JhaGFtTA==?=
Guest
Posts: n/a
 
      6th Oct 2006
Hi,

I have the following code to open in turn all files in a directory and run a
similar routine on them. The programming will recognise the file path, but my
"Fname" is blank and not picking up any of the files in the directory

Help gratefully recieved...

Private Sub ImportNew_Click()


Dim Fileloc As String
Dim Fname As String

Dim wkbk As Workbook


Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
Draft.rpt"
Fname = Dir(Fileloc & "*.rpt")

While Fname <> ""


Workbooks.OpenText FileDir & Fname

ConvertCostCenterMacro


Thanks

Graham
 
Reply With Quote
 
 
 
 
=?Utf-8?B?QWxvaw==?=
Guest
Posts: n/a
 
      6th Oct 2006
Your Fileloc string does not look OK. You should have the folder path here
including a \ (backslash) at the end. Together with "*.rpt" the Dir command
will look for all files ending of that type.


"GrahamL" wrote:

> Hi,
>
> I have the following code to open in turn all files in a directory and run a
> similar routine on them. The programming will recognise the file path, but my
> "Fname" is blank and not picking up any of the files in the directory
>
> Help gratefully recieved...
>
> Private Sub ImportNew_Click()
>
>
> Dim Fileloc As String
> Dim Fname As String
>
> Dim wkbk As Workbook
>
>
> Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> Draft.rpt"
> Fname = Dir(Fileloc & "*.rpt")
>
> While Fname <> ""
>
>
> Workbooks.OpenText FileDir & Fname
>
> ConvertCostCenterMacro
>
>
> Thanks
>
> Graham

 
Reply With Quote
 
=?Utf-8?B?R3JhaGFtTA==?=
Guest
Posts: n/a
 
      6th Oct 2006
Thanks..I have amended to

Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
Draft.rpt\ & *.rpt"

Fname = Dir(Fileloc)


....but still no joy ...Fname = ""

Graham


"Alok" wrote:

> Your Fileloc string does not look OK. You should have the folder path here
> including a \ (backslash) at the end. Together with "*.rpt" the Dir command
> will look for all files ending of that type.
>
>
> "GrahamL" wrote:
>
> > Hi,
> >
> > I have the following code to open in turn all files in a directory and run a
> > similar routine on them. The programming will recognise the file path, but my
> > "Fname" is blank and not picking up any of the files in the directory
> >
> > Help gratefully recieved...
> >
> > Private Sub ImportNew_Click()
> >
> >
> > Dim Fileloc As String
> > Dim Fname As String
> >
> > Dim wkbk As Workbook
> >
> >
> > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> > Draft.rpt"
> > Fname = Dir(Fileloc & "*.rpt")
> >
> > While Fname <> ""
> >
> >
> > Workbooks.OpenText FileDir & Fname
> >
> > ConvertCostCenterMacro
> >
> >
> > Thanks
> >
> > Graham

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      6th Oct 2006
Graham,
The problem is that :
Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
Draft.rpt
already points to a single file ("NR6 Draft.rpt"), not a folder.
So you cannot add a file name to the end of that.

The containing folder is :
"C:\Documents and Settings\FINPORT03\My Documents\Share\"
Is that the folder want to search with Dir() ?

NickHK

"GrahamL" <(E-Mail Removed)> 级糶秎ン穝籇:85922697-B415-48FD-A245-(E-Mail Removed)...
> Thanks..I have amended to
>
> Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> Draft.rpt\ & *.rpt"
>
> Fname = Dir(Fileloc)
>
>
> ...but still no joy ...Fname = ""
>
> Graham
>
>
> "Alok" wrote:
>
>> Your Fileloc string does not look OK. You should have the folder path
>> here
>> including a \ (backslash) at the end. Together with "*.rpt" the Dir
>> command
>> will look for all files ending of that type.
>>
>>
>> "GrahamL" wrote:
>>
>> > Hi,
>> >
>> > I have the following code to open in turn all files in a directory and
>> > run a
>> > similar routine on them. The programming will recognise the file path,
>> > but my
>> > "Fname" is blank and not picking up any of the files in the directory
>> >
>> > Help gratefully recieved...
>> >
>> > Private Sub ImportNew_Click()
>> >
>> >
>> > Dim Fileloc As String
>> > Dim Fname As String
>> >
>> > Dim wkbk As Workbook
>> >
>> >
>> > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
>> > Draft.rpt"
>> > Fname = Dir(Fileloc & "*.rpt")
>> >
>> > While Fname <> ""
>> >
>> >
>> > Workbooks.OpenText FileDir & Fname
>> >
>> > ConvertCostCenterMacro
>> >
>> >
>> > Thanks
>> >
>> > Graham



 
Reply With Quote
 
=?Utf-8?B?QWxvaw==?=
Guest
Posts: n/a
 
      6th Oct 2006
See NikHK's response. On the other hand if your folder is named
"C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> Draft.rpt\" then you do not need & in the Fileloc string. It should be

Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
Draft.rpt\*.rpt"

"GrahamL" wrote:

> Thanks..I have amended to
>
> Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> Draft.rpt\ & *.rpt"
>
> Fname = Dir(Fileloc)
>
>
> ...but still no joy ...Fname = ""
>
> Graham
>
>
> "Alok" wrote:
>
> > Your Fileloc string does not look OK. You should have the folder path here
> > including a \ (backslash) at the end. Together with "*.rpt" the Dir command
> > will look for all files ending of that type.
> >
> >
> > "GrahamL" wrote:
> >
> > > Hi,
> > >
> > > I have the following code to open in turn all files in a directory and run a
> > > similar routine on them. The programming will recognise the file path, but my
> > > "Fname" is blank and not picking up any of the files in the directory
> > >
> > > Help gratefully recieved...
> > >
> > > Private Sub ImportNew_Click()
> > >
> > >
> > > Dim Fileloc As String
> > > Dim Fname As String
> > >
> > > Dim wkbk As Workbook
> > >
> > >
> > > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> > > Draft.rpt"
> > > Fname = Dir(Fileloc & "*.rpt")
> > >
> > > While Fname <> ""
> > >
> > >
> > > Workbooks.OpenText FileDir & Fname
> > >
> > > ConvertCostCenterMacro
> > >
> > >
> > > Thanks
> > >
> > > Graham

 
Reply With Quote
 
=?Utf-8?B?R3JhaGFtTA==?=
Guest
Posts: n/a
 
      6th Oct 2006
Hi,

Thanks and sorry to add to the confusion...my folder is actually called NR6
Draft . rpt and contains a multitude of other files with .rpt file type. This
routine ran perfectly well for years, but I have recently transfered to XL
2000 from 97 version which must have something to do with the problem.

Graham


"NickHK" wrote:

> Graham,
> The problem is that :
> Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> Draft.rpt
> already points to a single file ("NR6 Draft.rpt"), not a folder.
> So you cannot add a file name to the end of that.
>
> The containing folder is :
> "C:\Documents and Settings\FINPORT03\My Documents\Share\"
> Is that the folder want to search with Dir() ?
>
> NickHK
>
> "GrahamL" <(E-Mail Removed)> 录露录g漏贸露l楼贸路s禄D:85922697-B415-48FD-A245-(E-Mail Removed)...
> > Thanks..I have amended to
> >
> > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> > Draft.rpt\ & *.rpt"
> >
> > Fname = Dir(Fileloc)
> >
> >
> > ...but still no joy ...Fname = ""
> >
> > Graham
> >
> >
> > "Alok" wrote:
> >
> >> Your Fileloc string does not look OK. You should have the folder path
> >> here
> >> including a \ (backslash) at the end. Together with "*.rpt" the Dir
> >> command
> >> will look for all files ending of that type.
> >>
> >>
> >> "GrahamL" wrote:
> >>
> >> > Hi,
> >> >
> >> > I have the following code to open in turn all files in a directory and
> >> > run a
> >> > similar routine on them. The programming will recognise the file path,
> >> > but my
> >> > "Fname" is blank and not picking up any of the files in the directory
> >> >
> >> > Help gratefully recieved...
> >> >
> >> > Private Sub ImportNew_Click()
> >> >
> >> >
> >> > Dim Fileloc As String
> >> > Dim Fname As String
> >> >
> >> > Dim wkbk As Workbook
> >> >
> >> >
> >> > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> >> > Draft.rpt"
> >> > Fname = Dir(Fileloc & "*.rpt")
> >> >
> >> > While Fname <> ""
> >> >
> >> >
> >> > Workbooks.OpenText FileDir & Fname
> >> >
> >> > ConvertCostCenterMacro
> >> >
> >> >
> >> > Thanks
> >> >
> >> > Graham

>
>
>

 
Reply With Quote
 
NickHK
Guest
Posts: n/a
 
      6th Oct 2006
Alok,
I did assume that
Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
Draft.rpt"
actually referred to file, rather than a folder with a "." in the name,
which would be valid.

But you response covers that.

NickHK

"Alok" <(E-Mail Removed)> 级糶秎ン穝籇:A8D21844-079B-4024-B07B-(E-Mail Removed)...
> See NikHK's response. On the other hand if your folder is named
> "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
>> Draft.rpt\" then you do not need & in the Fileloc string. It should be

> Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> Draft.rpt\*.rpt"
>
> "GrahamL" wrote:
>
>> Thanks..I have amended to
>>
>> Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
>> Draft.rpt\ & *.rpt"
>>
>> Fname = Dir(Fileloc)
>>
>>
>> ...but still no joy ...Fname = ""
>>
>> Graham
>>
>>
>> "Alok" wrote:
>>
>> > Your Fileloc string does not look OK. You should have the folder path
>> > here
>> > including a \ (backslash) at the end. Together with "*.rpt" the Dir
>> > command
>> > will look for all files ending of that type.
>> >
>> >
>> > "GrahamL" wrote:
>> >
>> > > Hi,
>> > >
>> > > I have the following code to open in turn all files in a directory
>> > > and run a
>> > > similar routine on them. The programming will recognise the file
>> > > path, but my
>> > > "Fname" is blank and not picking up any of the files in the directory
>> > >
>> > > Help gratefully recieved...
>> > >
>> > > Private Sub ImportNew_Click()
>> > >
>> > >
>> > > Dim Fileloc As String
>> > > Dim Fname As String
>> > >
>> > > Dim wkbk As Workbook
>> > >
>> > >
>> > > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
>> > > Draft.rpt"
>> > > Fname = Dir(Fileloc & "*.rpt")
>> > >
>> > > While Fname <> ""
>> > >
>> > >
>> > > Workbooks.OpenText FileDir & Fname
>> > >
>> > > ConvertCostCenterMacro
>> > >
>> > >
>> > > Thanks
>> > >
>> > > Graham



 
Reply With Quote
 
=?Utf-8?B?VG9tIE9naWx2eQ==?=
Guest
Posts: n/a
 
      6th Oct 2006

Fileloc = "C:\Documents and Settings\FINPORT03\" & _
"My Documents\Share\NR6 Draft.rpt\"
Fname = Dir(Fileloc & "*.rpt")

--
Regards,
Tom Ogilvy



"GrahamL" wrote:

> Hi,
>
> Thanks and sorry to add to the confusion...my folder is actually called NR6
> Draft . rpt and contains a multitude of other files with .rpt file type. This
> routine ran perfectly well for years, but I have recently transfered to XL
> 2000 from 97 version which must have something to do with the problem.
>
> Graham
>
>
> "NickHK" wrote:
>
> > Graham,
> > The problem is that :
> > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> > Draft.rpt
> > already points to a single file ("NR6 Draft.rpt"), not a folder.
> > So you cannot add a file name to the end of that.
> >
> > The containing folder is :
> > "C:\Documents and Settings\FINPORT03\My Documents\Share\"
> > Is that the folder want to search with Dir() ?
> >
> > NickHK
> >
> > "GrahamL" <(E-Mail Removed)> 录露录g漏贸露l楼贸路s禄D:85922697-B415-48FD-A245-(E-Mail Removed)...
> > > Thanks..I have amended to
> > >
> > > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> > > Draft.rpt\ & *.rpt"
> > >
> > > Fname = Dir(Fileloc)
> > >
> > >
> > > ...but still no joy ...Fname = ""
> > >
> > > Graham
> > >
> > >
> > > "Alok" wrote:
> > >
> > >> Your Fileloc string does not look OK. You should have the folder path
> > >> here
> > >> including a \ (backslash) at the end. Together with "*.rpt" the Dir
> > >> command
> > >> will look for all files ending of that type.
> > >>
> > >>
> > >> "GrahamL" wrote:
> > >>
> > >> > Hi,
> > >> >
> > >> > I have the following code to open in turn all files in a directory and
> > >> > run a
> > >> > similar routine on them. The programming will recognise the file path,
> > >> > but my
> > >> > "Fname" is blank and not picking up any of the files in the directory
> > >> >
> > >> > Help gratefully recieved...
> > >> >
> > >> > Private Sub ImportNew_Click()
> > >> >
> > >> >
> > >> > Dim Fileloc As String
> > >> > Dim Fname As String
> > >> >
> > >> > Dim wkbk As Workbook
> > >> >
> > >> >
> > >> > Fileloc = "C:\Documents and Settings\FINPORT03\My Documents\Share\NR6
> > >> > Draft.rpt"
> > >> > Fname = Dir(Fileloc & "*.rpt")
> > >> >
> > >> > While Fname <> ""
> > >> >
> > >> >
> > >> > Workbooks.OpenText FileDir & Fname
> > >> >
> > >> > ConvertCostCenterMacro
> > >> >
> > >> >
> > >> > Thanks
> > >> >
> > >> > Graham

> >
> >
> >

 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

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


Similar Threads
Thread Thread Starter Forum Replies Last Post
How to: obtain the filename that a module exists in, via VBA? =?Utf-8?B?S2V2aW4gTWNDYXJ0bmV5?= Microsoft Excel Programming 4 26th Jan 2010 06:55 AM
HttpPostedFile.saveas(filename) issue when the filename is used "-" as a part of the filename. Ken Microsoft Dot NET Framework 0 25th Feb 2009 10:58 PM
how to obtain filename behind trace listener using TraceSource =?Utf-8?B?aGVyYmVydA==?= Microsoft Dot NET 1 3rd Nov 2006 01:52 PM
auto text: the word Filename precedes the actual filename. =?Utf-8?B?c2htdWVsZ2ltbWVs?= Microsoft Word Document Management 0 23rd Mar 2005 06:59 PM
How to obtain a path and filename from an OLE bound object Martin Microsoft Access Forms 0 19th Nov 2003 05:03 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 12:42 PM.