SimonGeoghegan
Board Regular
- Joined
- Nov 5, 2013
- Messages
- 68
Hi All,
I have some VBA code within Microsoft Word that loops through and creates a number of mail merged documents.
When running, I receive a "Run-time error 4605: This command is not available" error message. When I debug the code, is it stopping on the "ActiveDocument.Range.Paste" line below. Once at the debug screen, if I then continue the code (F5) straight away, it works as expected, until the loop comes around to this same section.
I can execute all of my code if I sit and debug & F5 each time it breaks - but I'd prefer not to
Does anyone have any idea as to why the above section of code might be failing initially?
Thanks in advance!
Simon
I have some VBA code within Microsoft Word that loops through and creates a number of mail merged documents.
When running, I receive a "Run-time error 4605: This command is not available" error message. When I debug the code, is it stopping on the "ActiveDocument.Range.Paste" line below. Once at the debug screen, if I then continue the code (F5) straight away, it works as expected, until the loop comes around to this same section.
VBA Code:
Set Doc = ActiveDocument
Doc.Range.Copy
Documents.Add
ActiveDocument.Range.Paste
ActiveDocument.SaveAs (strPath & "\" & ReportingMonth & "\" & "Clinical Governance Report - " & ReportingMonth & " - " & Hospital & ".doc")
ActiveDocument.Close False
I can execute all of my code if I sit and debug & F5 each time it breaks - but I'd prefer not to
Does anyone have any idea as to why the above section of code might be failing initially?
Thanks in advance!
Simon