Word Macro to print all active docs to PC Folder

cjmitton

Board Regular
Joined
Sep 17, 2008
Messages
65
We have a document production system that gives crazy filenames / directory structure thats a nightmare to navigate around. Usually this is not an issue as we view them through the system and alls well!

Since we've had a little change to the way our business works we need to send 6 or so documents to clients via a 'portal'.

Due to the way the documents are named, its imposible to navigate to where the files are stored on the server, then select the files we need to 'upload' to the portal. What the current solution is that the users uses the system to open the relevent files (usually between 6 to 8 docs) then save each one, one by one to the 'My Documents' folder. Do the upload then delete them so we're not keeping anything on the PC.

I want to create a macro in Word 2010 to do a 'save as' on all active word documents. I've had and try a failed with my own usual style as I have no idea on how to 'find' the active word documents running?

Any help would be great.
 

Excel Facts

Repeat Last Command
Pressing F4 adds dollar signs when editing a formula. When not editing, F4 repeats last command.
Hi cjmitton,

Try something along the lines of:
Code:
Sub Demo()
Dim wdDoc As Document
For Each wdDoc In Documents
  With wdDoc
    .SaveAs FileName:=Options.DefaultFilePath(wdDocumentsPath) & "\" & .Name, _
      AddToRecentFiles:=False
    .Close
  End With
Next
End Sub
The above code saves all open documents to the user's default save location, then closes the file - you may want to change either behaviour.
 
Upvote 0
Thanks for the reply! its so close...

The Macro works but stops halfway through? My guess is that the instance of word that is running the macro is closed?

Any ideas, I've tried running from a blank document and it still happens?
 
Upvote 0
Hi cjmitton,

It would probably be best for the macro to be added to either your Normal template. If you add it to another document (preferably not one of the ones you're working on), the macro needs to be coded along the lines of:
Code:
Sub Demo()
Dim wdDoc As Document
For Each wdDoc In Documents
  With wdDoc
    If .Name <> ActiveDocument.Name Then
      .SaveAs FileName:=Options.DefaultFilePath(wdDocumentsPath) & "\" & .Name, _
        AddToRecentFiles:=False
      .Close
    End If
  End With
Next
End Sub
 
Upvote 0

Forum statistics

Threads
1,225,537
Messages
6,185,513
Members
453,298
Latest member
Adam1258

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top