ExcelBanter

ExcelBanter (https://www.excelbanter.com/)
-   Excel Programming (https://www.excelbanter.com/excel-programming/)
-   -   Save active sheet as "filename" on a remote server with username and password (https://www.excelbanter.com/excel-programming/389212-save-active-sheet-filename-remote-server-username-password.html)

Teddy[_3_]

Save active sheet as "filename" on a remote server with username and password
 
Hi gurus

(I know many of you are :-)

How do I sav a file on a network server I am not mapped up to?
I must provide a username and password.
How do I set in username and password for the server into the code???

v_FULLPATH_FILE_NAME =\\servername\driveletter$\folder\subfolder
\filename"

Application.ScreenUpdating = False
Inst.Copy ' name of the sheet
With ActiveSheet.Parent
Application.DisplayAlerts = False
.SaveAs Filename:=v_FULLPATH_FILE_NAME, FileFormat:=xlText
.Close SaveChanges:=False
Application.DisplayAlerts = True
MsgBox "Data saved"
End With
Application.ScreenUpdating = True


Vergel Adriano

Save active sheet as "filename" on a remote server with username a
 
Teddy,

I think you will have to map to the network location. Here's an example
that will map the network location to drive Z and then unMap it at the end...

Sub trythis()

Dim strNetworkPath As String
Dim objNet As Object


strNetworkPath = "\\servername\driveletter$\folder\subfolder"

Set objNet = CreateObject("Wscript.Network")
objNet.MapNetworkDrive "Z:", strNetworkPath, False, "domain\username",
"password"

Application.ScreenUpdating = False
Inst.Copy ' name of the sheet
With ActiveSheet.Parent
Application.DisplayAlerts = False
.SaveAs Filename:=strNetworkPath & "\sample.xls", FileFormat:=xlText
.Close SaveChanges:=False
Application.DisplayAlerts = True
MsgBox "Data saved"
End With
Application.ScreenUpdating = True

objNet.RemoveNetworkdrive "Z:"
Set objNet = Nothing

End Sub


--
Hope that helps.

Vergel Adriano


"Teddy" wrote:

Hi gurus

(I know many of you are :-)

How do I sav a file on a network server I am not mapped up to?
I must provide a username and password.
How do I set in username and password for the server into the code???

v_FULLPATH_FILE_NAME =\\servername\driveletter$\folder\subfolder
\filename"

Application.ScreenUpdating = False
Inst.Copy ' name of the sheet
With ActiveSheet.Parent
Application.DisplayAlerts = False
.SaveAs Filename:=v_FULLPATH_FILE_NAME, FileFormat:=xlText
.Close SaveChanges:=False
Application.DisplayAlerts = True
MsgBox "Data saved"
End With
Application.ScreenUpdating = True



urkec

Save active sheet as "filename" on a remote server with username a
 
"Teddy" wrote:

Hi gurus

(I know many of you are :-)

How do I sav a file on a network server I am not mapped up to?
I must provide a username and password.
How do I set in username and password for the server into the code???

v_FULLPATH_FILE_NAME =\\servername\driveletter$\folder\subfolder
\filename"

Application.ScreenUpdating = False
Inst.Copy ' name of the sheet
With ActiveSheet.Parent
Application.DisplayAlerts = False
.SaveAs Filename:=v_FULLPATH_FILE_NAME, FileFormat:=xlText
.Close SaveChanges:=False
Application.DisplayAlerts = True
MsgBox "Data saved"
End With
Application.ScreenUpdating = True



Hi Teddy,

It is not a good idea to store your passwords
in a text file.

I think the usual way to do what you want is
to share the folder where your files will be
saved, create a group, grant that group read/write
permissions on that folder, and add all the
users that will be saving Excel files to the group.
The details will depend on your network settings
(Workgroup or AD etc.)

You should probably contact your admin for that.

Hope this helps some.

--
urkec


All times are GMT +1. The time now is 08:33 AM.

Powered by vBulletin® Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
ExcelBanter.com