saving to two drives via macro

J

Jaymac

Hi folks

I am trying to save the same file to two separate drives via a macro. I
have cobbled together the following code from the VBA help files but it will
only save to the first drive. The pathname is the same on both drives with
the exception of tghe drive letter.
Set fd = Application.FileDialog(msoFileDialogSaveAs)
Dim vrtSelectedItem, vrtsave As Variant


With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems

vrtsave = "I" & Mid(vrtSelectedItem, 2, Len(vrtSelectedItem) - 1)
Next vrtSelectedItem
Else
End If

If .Show = -1 Then
Select Case .DialogType
Case msoFileDialogSaveAs: .Execute
Case Else
End Select
Else
End If
vrtSelectedItem = vrtsave
MsgBox "The path is: " & vrtSelectedItem
Select Case .DialogType
Case msoFileDialogSaveAs: .Execute
Case Else
End Select
End With
End Sub

I would appreciate any help I can get

Many thanks

Jack
 
D

Doug Robbins - Word MVP

Use the following macro.

Sub FileSaveAs()
Dim fname As String
Dim fsaved As Boolean
With Dialogs(wdDialogFileSaveAs)
If .Show = -1 Then
fsaved = True
Else
fsaved = False
End If
End With
If fsaved = True Then
fname = ActiveDocument.FullName
ActiveDocument.SaveAs "D" & Mid(fname, 2) 'Replace D with the required
drive letter
ActiveDocument.Close 'Close the copy
Documents.Open fname 'Re-open the original
End If
End Sub


--
Hope this helps.

Please reply to the newsgroup unless you wish to avail yourself of my
services on a paid consulting basis.

Doug Robbins - Word MVP
 
J

Jaymac

Hi guys

Doug Robbins' macro answers my query - many thanks Doug. Would recommend
this to anyone who hates doing backups.

Jack

PS You may see this query posted again (maybe even twice) as the system
reported it was unable to accept the post.

J
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top