I am trying to save a word document, after making automated changes, to a different folder and with a different name.
I am finding the file path of the original document, saving it in a sub-folder "Student Reports" and then giving the new document a name taken from a table within the original document.
If I use the code below I get the error: Unable to save .... File permission error....Run time error 5487.
If I change the 4th and 5th lines and set the StuName to "Test" then it saves correctly.
There would appear to be a problem with the variable obtained from the ActiveDocument.Table, but I can't seem to solve the problem.
The message box line is to check that the created filepath is correct - which it is.
I'm using Office 2010 and Windows 7.
Can anybody help please?

The code I using is:

Filepath = ThisDocument.FullName
FileOnly = ThisDocument.Name
PathOnly = Left(Filepath, Len(Filepath) - Len(FileOnly))


StuName = ActiveDocument.Tables(1).Cell(4, 2)
' StuName = "Test"

StuPath = PathOnly & "Student Reports" & StuName
strfilename = StuPath
' MsgBox StuPath
ActiveDocument.SaveAs FileName:=strfilename