VBA Error 4605 This method or property is not available because the document is in modal state

Viewed 1824

Environment: Word 2016 for Mac.

The following code (which works fine in Word 2007 and 2010 for PC and Word 2011 for Mac) throws run time error 4605 at the point of the paste:

Set oSubRange = wdDoc.Sections(i).Range ' we are in a loop...            
oSubRange.End = oSubRange.End - 1 
oSubRange.Copy
Set wdSubDoc = Documents.Add
wdSubDoc.Activate
Set oRange = wdSubDoc.Content
oRange.Collapse (wdCollapseEnd)
oRange.PasteAndFormat (wdFormatOriginalFormatting)

My thoughts were that maybe this was a sandboxing problem, but I don't think so because I have had no issues with saving files, and this is not at the point of save anyhow. Other thoughts were that the clipboard was not copying, that perhaps there was a timing issue. I tried inserting a DoEvents() after the copy as I have seen this suggested in different error 4605 scenarios (different error though). Also tried using ActiveDocument.Range.PasteAndFormant(wdFormatOriginalFormatting) which was suggested in another forum by a MS MVP (again, different error 4605). None of these solutions worked.

So, I am stuck.

0 Answers
Related