I get an error running a SaveAs routine where the message says it cannot access the file 'C:\Users\<user>\Documents\Root\Reports\057B2600'
I don't understand where the 057B2600 number is coming from at the end of the path name. Reports directory is where the file is to be saved as in. The directory path is correct and all the variables are declared.
As a sidenote, the directory structure was created using a shell cmd routine, but that shouldn't make a difference.</user>
I don't understand where the 057B2600 number is coming from at the end of the path name. Reports directory is where the file is to be saved as in. The directory path is correct and all the variables are declared.
Code:
Sub SaveReport()
Dim user$, pName$, sPath$
Set wb = Workbooks(1)
wb.Activate
Set ws = ThisWorkbook.Worksheets(1)
ws.Activate
user = Environ("username")
pName = Range("F2").value
sPath = "C:\Users\" & user & "\Documents\Tester\Reports\" & pName & ".xlsm"
With ws
Application.DisplayAlerts = False
.SaveAs Filename:=sPath, FileFormat:=xlOpenXMLWorkbookMacroEnabled
MsgBox "The " & pName & " project has been saved to your local Directory." & vbNewLine & "A shortcut to" & _
"the report and the well folder can be accessed on your desktop.", vbInformation, pName & "Well File"
Exit Sub
Application.DisplayAlerts = True
End With
End Sub
As a sidenote, the directory structure was created using a shell cmd routine, but that shouldn't make a difference.</user>