I am trying to save a copy of my file using vba on a network drive. The code was working fine earlier however it has stopped working and gives Subscript our of range error.
As per the debug, code throws this error when I invoke Workbooks(FName).Close call.
> Sub Macro2()
>
> Call Macrocopy
>
> Dim FName As String Dim BrandName As String Dim BDName As String DimsPath As String
>
> sPath = ThisWorkbook.FullName ActiveWorkbook.Save
>
>
> BrandName = Worksheets("Hidden").Range("B2").Value BDName =
> Worksheets("Hidden").Range("B6").Value
>
> FName = "\\dept-as\Groupdata1\Sales Strategy\account plan\" &
> BrandName & BDName & Format(Now(), "DD-MM-YYYY hh-mm-ss") & ".xlsm"
> BrandName = Worksheets("Hidden").Range("B2").Value
>
> ChDir "\\dept-as\Groupdata1\Sales Strategy\account plan\"
> ActiveWorkbook.SaveAs Filename:=FName, FileFormat:=xlOpenXMLWorkbookMacroEnabled, CreateBackup:=False
>
>
> Application.Workbooks.Open (sPath)
>
> Workbooks(FName).Close