(Solved) – Variable not being consistant in excel vba macro

(solved)-–-variable-not-being-consistant-in-excel-vba-macro

I have a macro in excel that if a drive exists the macro saves the file to my harddrive and thumbdrive. If it doesn’t exist, it saves to the harddrive. When the macro runs I am getting an error. Here is the macro:

Sub SaveFile()

Dim fso As Scripting.FileSystemObject
Set fso = New Scripting.FileSystemObject

Dim filepath As String

name = "Siemens"
filepath = "F:Dave backupOpen OrdersLabel ManifestsActive  Labels ManifestManifest RelatedFile saving testing folder" & name & "" & name & " Manifest " & Format(Now, "mm-dd-yyyy")

 If fso.DriveExists("F:") = True Then

        'ActiveWorkbook.SaveAs filename:="C:UsersdgrayDocuments" & name & " Manifest " & Format(Now, "mm-dd-yyyy")
        'ActiveWorkbook.SaveAs filename:="F:Dave backupOpen Orders" & name & "" & name & " Manifest " & Format(Now, "mm-dd-yyyy")
        ActiveWorkbook.SaveAs filename:=filepath
    Else

         'ActiveWorkbook.SaveAs filename:="C:UsersdgrayDocuments" & name & " Manifest " & Format(Now, "mm-dd-yyyy")
        ActiveWorkbook.SaveAs filename:="F:Dave backupOpen OrdersLabel ManifestsActive  Labels ManifestManifest RelatedFile saving testing folder" & name & "" & name & " Manifest " & Format(Now, "mm-dd-yyyy")


    End If

End Sub

Here is the error I am getting:

Error Message

I don’t know if you can see but the last part of the error message says “Siemens8E555720. That should also say the customer name (i.e. Siemens). In the code I have set the customer name in the variable “name”. So why is it giving me this crazy error? All help is appreciated.

Leave a Reply

Your email address will not be published. Required fields are marked *