View Single Post
 
Old 06-30-2015, 08:05 AM
Rose roon Rose roon is offline Windows 7 64bit Office 2007
Novice
 
Join Date: Jun 2015
Posts: 28
Rose roon is on a distinguished road
Default copy active document to shared network drive

Hi,

I have to copy the active document in shared network drive
I am using this macro, it is giving the error access denied.
But read and write permissions are there for this folder.
Please advice

Appreciate your help

Private Function access_Network_share()
On Error GoTo ErrHandler
ServerShare = "\\USER1-PC\MetaData"
userName = txtUserName.Text
Password = txtPassword.Text
Set NetworkObject = CreateObject("WScript.Network")
NetworkObject.MapNetworkDrive "", ServerShare, False, userName, Password
save_As_word
NetworkObject.RemoveNetworkDrive ServerShare, True, False
Set NetworkObject = Nothing
Exit Function
ErrHandler:
MsgBox "Please check your credentials"
End Function

Private Function save_As_word()
On Error GoTo ErrHandler

Kill "D:\Metadata\" & (ActiveDocument.Name) & ".DOCX"
ActiveDocument.SaveAs "\\USER1-PC\MetaData\" & (ActiveDocument.Name)
Exit Function
ErrHandler:
End Function

Regards,
Rose
Reply With Quote