Save as to two folders

  • Thread starter Thread starter HelpMe
  • Start date Start date
H

HelpMe

Here is my problem I have a save as command as follows:

ActiveWorkbook.SaveAs _
Filename:="L:\" & JobNoTXT.Value & "\xldata\" & ComboBox1.Value & ".xl
"

The "xldata" is the Sub folder and has a new name in new projects whic
is "Design Data" is there a way to save to the "xldata" and if that doe
not exist to save to the other name "Design Data"

Thanks for any help. :
 
Maybe you could just try to save and check for an error.

(I didn't test this)

Option Explicit
Sub testme02()

Dim iCtr As Long
Dim mySubFolderNames As Variant
Dim myErrNumber As Long

mySubFolderNames = Array("xldata", "design data")

For iCtr = LBound(mySubFolderNames) To UBound(mySubFolderNames)
On Error Resume Next
ActiveWorkbook.SaveAs _
Filename:="L:\" & JobNoTXT.Value & "\" & _
mySubFolderNames(iCtr) & "\" & _
ComboBox1.Value & ".xls"
myErrNumber = Err.Number
Err.Clear
On Error GoTo 0
If myErrNumber = 0 Then
MsgBox "Saved to: " & ActiveWorkbook.FullName
Exit For
End If
Next iCtr

End Sub



This does assume that nothing else could go wrong (drive not mapped/file already
exists and is marked readonly).
 

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

Back
Top