Click here to Skip to main content
14,304,170 members
Rate this:
Please Sign up or sign in to vote.
See more:
The code snippet "selection.GoTo" below worked in Windows 7 using Word 2010. But, in Windows Windows 10,
Word 2013 produces the following error:

An error occured: This method or property is not available because this command is not available for reading.

Does anyone know why and how to fix it ?

Code snippet:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using Microsoft.Win32;
using System.Diagnostics;
using Word = Microsoft.Office.Interop.Word;

for (var pageIndex = 1; pageIndex <= pageCount; ++pageIndex)
    var selection = winword.Selection;

        What: Word.WdGoToItem.wdGoToPage,
        Which: Word.WdGoToDirection.wdGoToAbsolute,
        Count: pageIndex);

    var curPage1 = selection.Information[Word.WdInformation.wdActiveEndAdjustedPageNumber];
    var curPage2 = selection.Information[Word.WdInformation.wdActiveEndPageNumber];

    winword.ActiveWindow.ActivePane.View.SeekView = Word.WdSeekView.wdSeekCurrentPageFooter;

    Word.Range range = selection.HeaderFooter.Range;

What I have tried:

google search and asking others
Updated 28-Jul-19 21:25pm
Maciej Los 4-Mar-18 13:37pm
What is exact and entire error message?
Rate this:
Please Sign up or sign in to vote.

Solution 1

Rate this:
Please Sign up or sign in to vote.

Solution 2

I had the same problem.

It is possible that your documents are being opened in preview mode rather than PrintView mode.  It appears that automation does not work unless the word document is in the correct viewing mode!!!

Try adding this to your code before the goto line:

winword.ActiveWindow.View.Type = WdViewType.wdPrintView;

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100