Wie man die Seitenzahl?
Habe ich diesen code:
Microsoft.Office.Interop.Word.Application app = new Microsoft.Office.Interop.Word.Application();
object nullobj = System.Reflection.Missing.Value;
object file = openFileDialog1.FileName;
Microsoft.Office.Interop.Word.Document doc = app.Documents.Open(
ref file, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj,
ref nullobj, ref nullobj, ref nullobj);
doc.ActiveWindow.Selection.WholeStory();
doc.ActiveWindow.Selection.Copy();
IDataObject data = Clipboard.GetDataObject();
string text = data.GetData(DataFormats.Text).ToString();
textBox2.Text = text;
doc.Close(ref nullobj, ref nullobj, ref nullobj);
app.Quit(ref nullobj, ref nullobj, ref nullobj);
Aber es nicht wieder eine Seitenzahl. Wie bekomme ich die Seitenzahl?
Du musst angemeldet sein, um einen Kommentar abzugeben.
Blick auf dieses Beispiel:
http://www.c-sharpcorner.com/UploadFile/amrish_deep/WordAutomation05102007223934PM/WordAutomation.aspx
Speziell, Blick auf
Word.WdFieldType.wdFieldPage
undWord.WdFieldType.wdFieldNumPages
.Ich würde sagen, dies ist eine bessere Lösung
Für mich, die ComputeStatistics-Funktion würde mir eine höhere Zahl als die tatsächliche Anzahl von Seiten, sodass nicht für mich arbeiten.
Ich verwendete Bereich.get_Information()
Der ersten Zeile wird der Bereich auf der letzten Seite des Dokuments.
Die zweite Zeile ruft die Seite, wo die Auswahl ist.