Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Network connect/disconnect

Status
Not open for further replies.

alpder

Technical User
Sep 22, 2002
103
AU
Hi,

I am setting up some programs in Excel for other users. The output will be sent to a remote computer. The connection requires path, username and password). I do not want the user to know the username and password, so I want to do the connection in VB code in Excel. After the output has been sent to the remote PC, I then need to disconnect the connection.
I look forward to your help.
 
Hi
This is a bit vague as a reply but should get you on your way.

One possible solution is to create a .bat file and call it from Excel (it may be possible to use the same commands as you would in the bat file in VBA but I've never done it so simply don't know)

The command for mapping a network path is 'net use but you'll need to check NT help for more info. To kill the connection it's net use z: /d where z is the drive you assign in the first place.

Use the Shell command to call the bat file from vba, like
Sub stitute()
Shell "?:\...full path...\a1.bat", vbMaximizedFocus
End Sub

;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Sorry but I need to be able to add username and password. For example - I want to map W: to \\myserver\data with userid = Fred and password ABC123

Has anyone used WnetAddConnection2? Would it solve my problem?
 
ok so the line you would need would be
net use w: \\myserver\data ABC123 /user:Fred
or something like that no time for more detail, you're probably better off with another solution. It was only a suggestion. Try reading some help files, this isn't my area of 'expertise'.

;-) If a man says something and there are no women there to hear him, is he still wrong?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top