View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
Alok Alok is offline
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