Results 1 to 3 of 3
  1. #1
    New Lounger
    Join Date
    Apr 2003
    Location
    Illinois, USA
    Posts
    14
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Automatic Backup to Floppy (Word 2k)

    I'm looking for a macro that will do the following function that is built in to WordPerfect:

    With a single click/keystroke, save my current file, then copy that file to a floppy (or, I suppose, CD-RW, or ZIP, or network, or in any event a different disk) WITHOUT changing my default save directory or filename. I've tried saving the current path directory as a variable, then saving to the desired backup location, then resetting the path directory--but that leaves the active file pointing to the backup, not the primary. I also cannot find an accurate way to pass a path name that includes spaces in it to a "just do a DOS copy" macro.

  2. #2
    Star Lounger
    Join Date
    Jun 2002
    Posts
    98
    Thanks
    1
    Thanked 0 Times in 0 Posts

    Re: Automatic Backup to Floppy (Word 2k)

    There is this command:
    <pre>FileCopy SourceFile, DestinationFile ' Copy source to target. </pre>

    But it won't work on a file that you have open in Word, so it's not too helpful here.

    To make sure you are left working on the C: copy you could save to A: first, then save to the C: folder you "captured".
    Try this code:
    <pre>OrigName = ActiveDocument.FullName
    ActiveDocument.SaveAs FileName:="A:" & ActiveDocument.Name
    ActiveDocument.SaveAs OrigName
    </pre>

    __________________________________________________ ____
    <img src=/S/nun.gif border=0 alt=nun width=20 height=20> Sister Dory
    Our Lady of Perpetual Help, Holstein Falls, Wisconsin, USA

  3. #3
    Super Moderator jscher2000's Avatar
    Join Date
    Feb 2001
    Location
    Silicon Valley, USA
    Posts
    23,112
    Thanks
    5
    Thanked 93 Times in 89 Posts

    Re: Automatic Backup to Floppy (Word 2k)

    Here's a trick: you can create a new document based on the saved version of your old document and save that in the backup location. You don't need to close the active document or change any paths. Go ahead and try this (customize the default string in the InputBox function to whatever is most common for you):

    <pre>Sub SaveAndCloneActiveDocument()
    ' 2003-05-21 Jefferson Scher
    Dim oldDoc As Document, strBackupPath As String, newDoc As Document
    ' Save the current active document
    Set oldDoc = ActiveDocument
    oldDoc.Save
    ' Solicit the backup path (this could drive a dialog instead...)
    strBackupPath = InputBox("Where to save backup?", , "a:")
    ' If blank, get out of here
    If strBackupPath = vbNullString Then GoTo lastExit
    ' Get on the end of the folder path
    If Not Right(strBackupPath, 1) = "" Then
    strBackupPath = strBackupPath & ""
    End If
    ' Create a new document based on the activedocument
    Set newDoc = Documents.Add(Template:=oldDoc.FullName, newtemplate:=False)
    ' Set its attached template to match the activedocument
    newDoc.AttachedTemplate = oldDoc.AttachedTemplate.FullName
    ' Save it on the backup path... hope it's valid!... overwrites without warning
    newDoc.SaveAs FileName:=strBackupPath & oldDoc.Name, fileFormat:=wdFormatDocument
    ' Close it and destroy its object variable
    newDoc.Close
    Set newDoc = Nothing
    lastExit:
    ' Re-activate the activedocument and destroy its object variable
    oldDoc.Activate
    Set oldDoc = Nothing
    End Sub</pre>

    Hope that makes sense. It's a bit fragile, as you can see from the comments, and not super-friendly. Not something I'd roll out to the masses without additional bulletproofing.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •