1.JavaScript: เปิด ActiveX ทั้งหมดในเบราว์เซอร์ IE ใช้หน้าเว็บต่อไปนี้เพื่อดูคำสั่งซื้อบุ๊กมาร์กและตำแหน่ง:
<html> <head> <script> var word; word = new ActiveXObject ("Word.Application"); ช่วง var = word.Range; word.visible = true; var path = "d: //xxx//xxx//xx.doc"; word.documents.open (path); document.write (word.activeDocument.bookmarks (i) .name); document.write (""); document.write (word.activeDocument.bookmarks (i) .range.bookmarkid); document.write ("</br>");} </script> </head> <body> </body> </html>Java: ใช้ POI เพื่อเปิดนี่คือไฟล์. doc ดังนั้นให้ใช้ชุด API แบบเก่า ถ้าเป็น docx หลักการก็เหมือนกัน
FileInputStream ใน = new FileInputStream ("D: //xxx//xxx//xx.doc"); hwpfdocument doc = ใหม่ hwpfdocument (in); bookmarks bookmarks = doc.getBookMarks (); Bookmarks.getBookmark (I); System.out.println (bookmark.getName ()); System.out.println (i); System.out.println (bookmark.getstart ());}