J
Jaymac
Hi folks
I am trying to write a macro to save a file to both my hard drive (C) and
USB external drive (I) for security/backup purposes. I haved put together
this macro from VBA help files but it only works for the first drive letter
selected. Apart from Drive letter the paths on both drives are identical.
The coding is as follows:
Sub Backup()
'
' Backup Macro
' Macro recorded 10/2/2009 by Jack McLean
'
Set fd = Application.FileDialog(msoFileDialogSaveAs)
Dim vrtSelectedItem, vrtsave As Variant
Dim DL As String
DL = "I"
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
If "I" = vrtSelectedItem Then DL = "C" Else DL = "I"
vrtsave = DL & 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 anyone can give
Many thanks
Jack
I am trying to write a macro to save a file to both my hard drive (C) and
USB external drive (I) for security/backup purposes. I haved put together
this macro from VBA help files but it only works for the first drive letter
selected. Apart from Drive letter the paths on both drives are identical.
The coding is as follows:
Sub Backup()
'
' Backup Macro
' Macro recorded 10/2/2009 by Jack McLean
'
Set fd = Application.FileDialog(msoFileDialogSaveAs)
Dim vrtSelectedItem, vrtsave As Variant
Dim DL As String
DL = "I"
With fd
If .Show = -1 Then
For Each vrtSelectedItem In .SelectedItems
If "I" = vrtSelectedItem Then DL = "C" Else DL = "I"
vrtsave = DL & 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 anyone can give
Many thanks
Jack