Word

SaveCopyAs Workaround for Word

Ease of Use

Easy

Version tested with

2003 

Submitted by:

lucas

Description:

Sometimes you wish to save a copy of your work to your hard drive but would like to keep the original document open to continue working on it. This routine will help 

Discussion:

Word has no built in savecopyas as does Excel. This is a workaround for that problem. It basically makes a copy of the original file, runs saveas on the copy and closes the copy leaving the original file open for further ediiting. 

Code:

instructions for use

			

The document With the code should be saved before running the code Place the following code In a standard module: Option Explicit Sub SaveCopyAs() Const lCancelled_c As Long = 0 Dim sSaveAsPath As String sSaveAsPath = GetSaveAsPath If VBA.LenB(sSaveAsPath) = lCancelled_c Then Exit Sub 'Save changes to original document ActiveDocument.Save 'the next line copies the active document Application.Documents.Add ActiveDocument.FullName 'the next line saves the copy to your location and name ActiveDocument.SaveAs sSaveAsPath 'next line closes the copy leaving you with the original document ActiveDocument.Close End Sub Public Function GetSaveAsPath() As String Dim fd As Office.FileDialog Set fd = Word.Application.FileDialog(msoFileDialogSaveAs) fd.InitialFileName = ActiveDocument.Name If fd.Show Then GetSaveAsPath = fd.SelectedItems(1) End Function

How to use:

  1. Open the Visual Basic Editor by going to tools-Macro's-Visual Basic Editor or use Alt-F11
  2. On the toolbar of the Visual Basic Editor, go to insert - module
  3. In the module pane paste the code above.
  4. Close the Visual Basic Editor by clicking the X in the upper right corner or go to File-Close
  5. Save your file
 

Test the code:

  1. On the main menu go to tools-macro-macros.
  2. In the dialog window select SaveCopyAs and then click run.
  3. In the attachment there is a button on the main menu to run the code.
 

Sample File:

savecopyas.zip 7.59KB 

Approved by mdmackillop


This entry has been viewed 250 times.

Please read our Legal Information and Privacy Policy
Copyright @2004 - 2020 VBA Express