1

I have a Windows 10 PC.

Basically I have a similar problem to this: How can I save a file to two locations at the same time?, but just the opposite. I have files on a USB stick, and I want them to be saved to my PC [or to a different USB stick] as a backup. As far as I know, that can't be done with without external software.

So I came up with a solution: Since I deal mostly with MS Word files, I recorded a macro that saves the file, and then saves it on my computer via 'save as' (and then closes it). But the problem is, that the macro records the file name when using 'save as', even if I didn't change the name. So when I save a different file, it gets the same name as the file I used when recording the macro, and the previous file gets replaced with the new one. I tried to enter the file name via copy-paste, but it still records the actual name.

I enabled Windows 'file history' to keep the history at a different USB stick, but it would be much better if I could do one of the following:

  1. Make the macro saving each file with its original name (or any unique name)
  2. Prevent the files from replacing each other

But I want it to happen automatically! Instead of clicking 'save' I click the macro and that's it. Please don't post answers/comments with solutions that doesn't happen automatically (after setting up, of course).

P.S. if you know of a backup software for Windows, that doesn't require even a single click (beyond the mentioned macro) after being set up, and is not expensive, I would be very interested in it.

4
  • May be so?
    – JohnSUN
    Commented May 5, 2023 at 18:09
  • You can get the open document's file-name in VBA using ThisDocument.Name. Isn't this enough to make you macro work? The full path is ThisDocument.FullName.
    – harrymc
    Commented May 5, 2023 at 18:17
  • Within Word, use of documents on a USB stick / Flash Drive is one of the top causes of document corruption. General rule is to work with the USB stick in Windows or Mac OS. I would recommend a Windows batch file using xCopy instead of doing this within Word. Commented May 6, 2023 at 13:02
  • @harrymc ThisDocument.Name entered normal.dotm. But thanks anyway, because you made me think that's ActiveDocument.Name, as I posted in my answer.
    – George Lee
    Commented May 8, 2023 at 22:42

1 Answer 1

0

After recording the macro, replace "Document1.docx" (where Document1 is just an example of the current document name) with ActiveDocument.Name to save the document with the current name.

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .