Search code examples
vbams-wordruntime-errorword-2013

Run-time Error: WordBasic Commands are not available for reading


I have a macro which has following calls of Wordbasic:

    WordBasic.StartOfDocument

    WordBasic.SetDocumentDirty 0

    WordBasic.SetTemplateDirty 0

When I run the code, it gives run time error:- These commands are not available for reading in word 2013. Whereas it is running fine with other versions of Word. There are lots of calls of WordBasic but I have changed them with ActiveDocument calls.

Is there any way to change these calls with ActiveDocument?


Solution

  • Selection.HomeKey Unit:=wdStory
    ActiveDocument.Saved = False
    ActiveDocument.AttachedTemplate.Saved = False
    

    In addition, in Word 2013 the documents are opened in Reading View by default. In that case, you may need to allow editing the document by setting

    ActiveWindow.View.ReadingLayout = False