Microsoft Office Forums

Go Back   Microsoft Office Forums > Microsoft Word > Word VBA

Reply
 
LinkBack Thread Tools Display Modes
  #1  
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
  #2  
Old 07-01-2015, 04:59 AM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,392
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

Have you checked where the code is generating the error? For example, I doubt this line would work:
Kill "D:\Metadata\" & (ActiveDocument.Name) & ".DOCX"
since ActiveDocument.Name will return the Active Document's name, including the extension...
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #3  
Old 07-01-2015, 06:06 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

Hi Paul,

Thanks, sorry
Kill "D:\Metadata\" & (ActiveDocument.Name) & ".DOCX" actually I have commented.

This issue need to fix urgently, using net use when we are copying able to copy.

Is it because I am using saveus, if i use copyfile will it be ok

ActiveDocument.SaveAs "\\USER1-PC\MetaData\" & (ActiveDocument.Name) is throwing the error as access denied.

Appreciate your help

Thanks& Regards,
Rose
Reply With Quote
  #4  
Old 07-01-2015, 06:43 AM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,392
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

From what I can see of your MapNetworkDrive method implementation, you've omitted the Drive name you want to map the server to. AFAIK, you need to map it to an available drive letter, which you then use for the Save As.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #5  
Old 07-01-2015, 07:55 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

Hi Paul,

Thanks for sharing, as per the user requirement cannot map the drive due to security.
only given share drive " "\\USER1-PC\MetaData\"" authenticate and copy the file

Thanks & Regards,
Rose
Reply With Quote
  #6  
Old 07-01-2015, 02:53 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,392
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

If you cannot map the drive, then why are you using the MapNetworkDrive method?
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #7  
Old 07-03-2015, 08:31 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

Hi Paul,

For the same code today I am getting error 4198 -command failed.
please advice

Thanks & Regards,
Rose
Reply With Quote
  #8  
Old 07-03-2015, 08:32 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,392
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

These really aren't Word issues - they're more related to Windows and, more specifically, networking, neither of which are my particular area of expertise. That said, you're not using the MapNetworkDrive method properly (i.e. you're not specifying a drive letter to map to) and you still haven't answered my question as to you're using the MapNetworkDrive method when you say there is a "user requirement cannot map the drive due to security".
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
  #9  
Old 07-04-2015, 08:07 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

Hi Paul,

Sorry just a beginner, want to check is there any way to save the active document in shared network drive by authentication with out mapping?

Thanks & Regards,
Rose
Reply With Quote
  #10  
Old 07-04-2015, 09:55 PM
macropod's Avatar
macropod macropod is online now Windows 7 64bit Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 19,392
macropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to beholdmacropod is a splendid one to behold
Default

That shouldn't be any different than saving to a local drive. If the network drive is shared, it's presumably already mapped to an alias (e.g. H: ) and you should be able to use that. Indeed, you should even be able to save direct to \\USER1-PC\Metadata.
__________________
Cheers,
Paul Edstein
[MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Live updating powerpoint playing on network drive flossin345 PowerPoint 0 10-10-2013 09:50 AM
Could not update file on the shared network drive with Office 2010 aldo4u Word 7 07-24-2013 07:56 AM
Office Crashing when saving to Network Drive robbid01 Office 1 01-05-2012 03:47 PM
Hyperlinking files on a mapped network drive howler2345 Outlook 0 12-21-2011 08:54 AM
Mail Merge and Files on Network Drive Joe Switch Mail Merge 0 09-15-2011 09:06 AM


All times are GMT -7. The time now is 03:25 PM.


Powered by vBulletin® Version 3.8.1
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
SEO by vBSEO ©2011, Crawlability, Inc.
MSOfficeForums.com is not affiliated with Microsoft