Quote:
Run-time error 4605 this method or property is not available because no text is selected
If you read carefully the error message, it tells you why there is an error. Chances are that it also tells you the line where error occurs, chances are that it also propose to open the debugger.
Advice: As you are debugging your code, keep screen update to see what is going on.
Private Sub CommandButton1_Click()
Stop
Application.Documents.Open ("C:\Users\shankrayya.g\Desktop\Test\Payslip.docx")
Application.Browser.Target = wdBrowsePage
For i = 1 To ActiveDocument.BuiltInDocumentProperties("Number of Pages")
ActiveDocument.Bookmarks("\page").Range.Copy
Documents.Add
Selection.Paste
Selection.TypeBackspace
Dim SSS As String
SSS = ActiveDocument.Range.Paragraphs(20).Range.Text
MsgBox SSS
SSS = Replace(SSS, Chr(13), "")
SSS = "C:\Users\shankrayya.g\Desktop\Test\Output\file" & SSS & ".doc"
MsgBox SSS
ActiveDocument.SaveAs FileName:=SSS
Next i
ActiveDocument.Close savechanges:=wdDoNotSaveChanges
End Sub
Chances are also that ActiveDocument switch as you Add a new document.
-----
Learn to indent properly your code, it show its structure and it helps reading and understanding. It also helps spotting structures mistakes.
Indentation style - Wikipedia[
^]
In excel, I use an addin "Smart Indenter v3.5", lets guess it works the same with word.