![]() |
|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
![]() Hi, I'm very, very new to VBA and am trying to create a macro that will duplicate all of the contents (including comments, markup, etc.) of an open document (that will most likely not have been saved on the computer as it will be opened directly from Sharepoint) and save it to the local computer (i.e. in Documents), and then close it, leaving the original document open. This is one macro that I want to occur before a set of other macros that clean up the document--I'm essentially trying to save the original one for backup purposes, so the additional clean-up macros should only be applied to the original opened document, not the newly duplicated one. I've searched around and have tried out a bunch of different codes with no luck. The current code that's gotten my the closest prompts the 'Save' dialogue, and I'm able to save it but then when I try to open it I get an error telling me it cannot be found. This is the current code I'm using: Sub Macro1() ' Macro1 Macro 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 "C:\Users\name\Documents" 'next line closes the copy leaving you with the original document ActiveDocument.Close End Sub I've also tried this one (via the Record function) and there seems to be an error in the bold line.This is copied from a larger macro so the sub/end macros aren't included: 'CopyDoc Macro Selection.WholeStory Selection.Copy Documents.Add DocumentType:=wdNewBlankDocument Selection.PasteAndFormat (wdUseDestinationStylesRecovery) ActiveDocument.Save ActiveDocument.SaveAs2 FileName:="StoryPackCopy123.docx", FileFormat:= _ wdFormatXMLDocument, LockComments:=False, Password:="", AddToRecentFiles _ :=True, WritePassword:="", ReadOnlyRecommended:=False, EmbedTrueTypeFonts _ :=False, SaveNativePictureFormat:=False, SaveFormsData:=False, _ SaveAsAOCELetter:=False, CompatibilityMode:=15 Windows("CRM Story Pack Phase 2").Activate Any and all help would be appreciated! |
Tags |
copy, save document, word vba |
Thread Tools | |
Display Modes | |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
My Word 10 won't open it's own saved files because it says they are corrupted | Dave Young | Word | 5 | 11-05-2016 09:13 PM |
Some images not saved when creating PDF from Word with Acrobat | WaltR | Word | 5 | 09-26-2015 02:58 PM |
![]() |
Rick K | Word | 2 | 05-06-2015 08:25 AM |
![]() |
otherlunds | Word | 1 | 09-01-2014 05:41 AM |
![]() |
doctor_who12 | Excel Programming | 1 | 01-22-2014 04:47 PM |