copying files form within Word

A

aalaan

Hi all

Word 2000. Complete beginner.

Trying to automate the current process of leaving Word and going into
Windows Explorer to copy files that have just been worked on to a memstick
(removable media). This is because one should never *save* to a memstick.

I'm trying to automate this from a special button on the Word toolbar while
actually in a given document. I know a file must be actually there on the
hard disk (ie first saved to the hard disk) and then it should be possible
to copy it. However, doing it from inside the document means that the system
thinks the document is still in use and refuses to copy it (copying an'open'
file). How can I overcome this?

I'm familiar with assigning a vba routine to a new toolbar button.

Here is the code I'm using:

Dim strFileA, strFileB

strFileA = ActiveDocument.Name 'so as know the name of the
document being copied
ActiveDocument.Close 'so the system thinks
it is still not open
strFileB = "F:\" & strFileA 'the path of the
desired copy
FileSystem.FileCopy strFileA, strFileB 'overwrite by default

I get 'permission denied' which I guess is the system saying this file is in
use (and therefore locked).

Any help would be appreciated.
 
H

Helmut Weber

Hi,

save the file as A,
save the file as B,
copy file A.

Do with B whatever you like.

HTH

--
Greetings from Bavaria, Germany

Helmut Weber, MVP WordVBA

Win XP, Office 2003
"red.sys" & Chr$(64) & "t-online.de"
 

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