PDA

View Full Version : Solved: Loop files on shared folder



Costy
02-14-2008, 08:47 AM
Haye everyone,

First post so be nice :D

I have a piece of code which basically loops through files on a shared folder. Only problem is that the server requires you to enter a username and password. I was wondering is there some sort of way I can:

A. Get VBA to enter them for me

B. Ask for them off the user

This is the path. Is there somewhere in the Path i can enter them?
Path = "\\server\budgets\" & Branch & "\"
This is where it fails (Error number 52)
strFile = Dir(Path & "*.bas")
Thankyou in advance to everyone! :D

CCkfm2000
02-14-2008, 09:57 AM
try this

Shell "net use X: \\server\budgets$ (file://server/budgets$) /user:DOMINE NAME\USERNAME PASSWORD"

Costy
02-15-2008, 02:07 AM
Not exactly what I was hoping for, don't really want to start mapping drives. Is there anyway to enter the username and password within the path ?

Thanks :D

Costy
02-15-2008, 03:57 AM
Is there anyway I can store a username and password within Windows from VBA. e.g. "go to run, type control userpasswords2"

Costy
02-15-2008, 08:42 AM
No worries all sorted now...I basically just used CCkfm2000's post.

Thankyou, much appreciated! :D