Originally Posted by
PJYelton
Sorry to rehash an old thread but a small problem has come up with this macro. If the document has no name then it uses SaveAs which is great, but if the user clicks cancel then theres a runtime error. What is the easiest way around this?
Code:
Sub PJYelton()
On Error Resume Next
Dim FileName As String
With ActiveDocument
.Save
FileName = .Name
With .Sections(1).Footers(wdHeaderFooterPrimary).Range
.Text = FileName
.ParagraphFormat.Alignment = wdAlignParagraphRight
End With
.Save
End With
End Sub