Mapping drive from vba

M

Maria

I need to have a word macro map a drive using a user
id/pwd (different from the one logged in), copy a file and
then unmap the drive - can this be done?

As an alternative, how do I copy a file to a drive without
allowing the user to use SaveAs to save files to this
drive?

Thans

Maria
 
D

Doug Robbins - Word MVP - DELETE UPPERCASE CHARACT

Hi Maria,

Here's a macro that saves a document and then makes a copy of it on another
(in this case the a: drive)

'Macro to save a file and make a copy on the A" drive

Dim SourceFile, DestinationFile

ActiveDocument.Save
SourceFile = ActiveDocument.Name ' Define source file name.
DestinationFile = "A:\" & SourceFile ' Define target file name.
ActiveDocument.Close
FileCopy SourceFile, DestinationFile ' Copy source to target
Documents.Open SourceFile

If you were to create macros with the name of Word's in-built commands
FileSave and FileSaveAs that contained this code, it would run whenever
those commands were used.

Please post any further questions or followup to the newsgroups for the
benefit of others who may be interested. Unsolicited questions forwarded
directly to me will only be answered on a paid consulting basis.
Hope this helps
Doug Robbins - Word MVP
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top