Click here to Skip to main content
15,897,334 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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:

C#
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;

    selection.GoTo(
        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
Posted
Updated 28-Jul-19 21:25pm
v2
Comments
Maciej Los 4-Mar-18 13:37pm    
What is exact and entire error message?

 
Share this answer
 
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;
 
Share this answer
 

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, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900