473,395 Members | 1,986 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

How to get all the bookmark names in a word file in C#

How to get all the bookmark names in a word file in C#
Many thanks for your replying.
Aug 20 '07 #1
2 6367
dip_developer
648 Expert 512MB
How to get all the bookmark names in a word file in C#
Many thanks for your replying.
try this code..........

Expand|Select|Wrap|Line Numbers
  1. Word.Application objWord;
  2. Word.Document objDoc;
  3. Word.Bookmark objBookMark;
  4. string strFile;
  5.  
  6. // Instansiate Microsoft Word
  7. objWord = new Word.Application();
  8.  
  9. // Allow session to be visible
  10. objWord.Visible = true;
  11.  
  12. strFile = path of your WORD file ;
  13.  
  14. // Open the document
  15. objDoc = objWord.Documents.Open(strFile);
  16.  
  17. foreach (objBookMark in objDoc.Bookmarks) 
  18. {
  19. MsgBox(objDoc.Bookmarks(objBookMark).Name());
  20. }
  21. //Release memory references 
  22. objBookMark = null;
  23. objDoc = null;
  24. objWord = null;
Aug 20 '07 #2
Wow!
This is so cool!
Thank you vey much.
try this code..........

Expand|Select|Wrap|Line Numbers
  1. Word.Application objWord;
  2. Word.Document objDoc;
  3. Word.Bookmark objBookMark;
  4. string strFile;
  5.  
  6. // Instansiate Microsoft Word
  7. objWord = new Word.Application();
  8.  
  9. // Allow session to be visible
  10. objWord.Visible = true;
  11.  
  12. strFile = path of your WORD file ;
  13.  
  14. // Open the document
  15. objDoc = objWord.Documents.Open(strFile);
  16.  
  17. foreach (objBookMark in objDoc.Bookmarks) 
  18. {
  19. MsgBox(objDoc.Bookmarks(objBookMark).Name());
  20. }
  21. //Release memory references 
  22. objBookMark = null;
  23. objDoc = null;
  24. objWord = null;
Aug 21 '07 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

6
by: Chris | last post by:
I have been learning C and want to write a program and need someone to point me in the write direction. I want to write a program to store all my webpage bookmarks in possibly one file. I want it...
1
by: adam lital | last post by:
Hi, I have word document and i want to replace a specific text with a bookmark using code. Example: in the document i have the text and i want to replace this to a bookmark called ClientName....
2
by: fordesky | last post by:
Gday, I have a set of Access 2000 tables that I would like to export into a MS Word 2000 template at specific bookmark locations that I've set up. Would anyone know the code to achieve...
0
by: sweetpotatop | last post by:
Hello, I have a locked Word document (save as XML) in which I need to fill out the bookmark through ASP.NET And part of the xml is shown below: <aml:annotation aml:id="0"...
1
by: jpr | last post by:
Hello friends, I have a good question for you. I have a form in Access with a check box named chk1. On the same form I have a code that export my data to a template in MS Word. I use bookmark to...
0
by: hayworth | last post by:
The new bookmark window is pretty nice. It shows you bookmarks, the filename where they are, and the line number of that file. You can even give custom names to the bookmarks, like "MainLoad" ...
2
by: Alan T | last post by:
How do I make use of the Bookmarks property so that I can write a text at/below the position of a particular bookmark or the first bookmark ? private Microsoft.Office.Interop.Word.Document...
0
by: Alan T | last post by:
My code can select the content of a Word document between 2 bookmarks: if (bookmarks.Exists("first bookmark") & bookmarks.Exists("second bookmark")) { object oFirstBookmark = ("first...
1
by: shiv264 | last post by:
Hello All, I am really struggling to figure out a method which could pull the Bookmark names created in MS Word. I can very much retrieve the count but unable to fugure out any property which...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.