Importing file name from server

Slade

New Member
Joined
Aug 5, 2011
Messages
26
Hi all.

I have a problem with a dir in vba script for excel. This is the code.

Code:
Sub FileName()
Dim sFil As String
Dim sPath As String
sPath = "C:\"
ChDir sPath
sFil = Dir("*.txt")
Do While sFil <> ""
Sheet1.Range("A1") = sFil
sFil = Dir
Loop
End Sub

Than it displays the text file that i do have for testing this and works grate. Then i have the exact same file on a server so then i tried this:

Code:
Sub FileName()
Dim sFil As String
Dim sPath As String
sPath = "\\mrmprd02\TRMFeeds\Today\IAFeeds"
ChDir sPath
sFil = Dir("*.txt")
Do While sFil <> ""
Sheet1.Range("A1") = sFil
sFil = Dir
Loop
End Sub

Then i get output of "To had code.txt" and there is no such fiel on that folder there is only the 1 text file that is named Test.txt. Then i mapped a drive to that folder and still did not work. Must i do something else?

Tnx allot
 

Excel Facts

Does the VLOOKUP table have to be sorted?
No! when you are using an exact match, the VLOOKUP table can be in any order. Best-selling items at the top is actually the best.

Forum statistics

Threads
1,224,602
Messages
6,179,848
Members
452,948
Latest member
UsmanAli786

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top