|
|
|
|
|
|
|
|
|
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:
|
- Open the Visual Basic Editor by going to tools-Macro's-Visual Basic Editor or use Alt-F11
- On the toolbar of the Visual Basic Editor, go to insert - module
- In the module pane paste the code above.
- Close the Visual Basic Editor by clicking the X in the upper right corner or go to File-Close
- Save your file
|
|
Test the code:
|
- On the main menu go to tools-macro-macros.
- In the dialog window select SaveCopyAs and then click run.
- 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 213 times.
|
|
|