There is within the script-execution no ActiveDocument because this will only created after script-execution - this must triggered per gui-event or per batch-run. Also ActiveDocument.Sheets needs the sheet-name and not the sheet-id - see APIGuide.qvw: