Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cannot obtain Filename

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
  #2   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Cannot obtain Filename

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

  #3   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cannot obtain Filename

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

  #4   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Cannot obtain Filename

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" ...
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



  #5   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 318
Default Cannot obtain Filename

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



  #6   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 3
Default Cannot obtain Filename

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" ...
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




  #7   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 415
Default Cannot obtain Filename

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" ...
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



  #8   Report Post  
Posted to microsoft.public.excel.programming
external usenet poster
 
Posts: 6,953
Default Cannot obtain Filename


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" ...
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
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
How to: obtain the filename that a module exists in, via VBA? Kevin McCartney Excel Programming 4 January 26th 10 06:55 AM
Converting a Variable Filename to a Constant Filename Magnivy Excel Programming 2 August 15th 06 06:13 PM
set filename to <filename-date on open bob engler Excel Worksheet Functions 2 July 13th 06 05:11 AM
set excel <filename to <filename-date bob engler Excel Programming 2 July 12th 06 08:22 AM
Saving filename same as import filename Matt Excel Programming 4 February 24th 04 03:01 PM


All times are GMT +1. The time now is 06:26 AM.

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

About Us

"It's about Microsoft Excel"