How can i get only the headings and their subheadings from word file in C#

I want to get all the headings along their sub-headings separately from a word file programmatically Using c# for example i have following content :
HEADING 1 XYZ
heading 2
heading 3
HEADING 1 ABC
HEADING 1 DEF
heading 2 lorem ispum
so my code should return me:
Heading 1 XYZ
heading 2
heading 3
seperately and similarly remaining headings and subheadings also.
Bilal Amjad Microsoft Certified Professional

Did you try to use OpenXml SDK to access word *.docx file in .Net?
Use OpenXml SDK you could easily to get anything in Word (Office) documents.
Bob Bao
Do you still use the same Windows 8 LockScreen always? Download Chameleon Win8 App quickly, that changes your LockScreen constantly.
你是否还在看着一成不变的Windows 8锁屏而烦恼,赶紧下载这个
百变锁屏
应用,让你的锁屏不断地变化起来。
 i am using the following code to get the output but it returns me all he headings and subheading together not separately 
 foreach (Microsoft.Office.Interop.Word.Paragraph paragraph in oMyDoc.Paragraphs )
                    Microsoft.Office.Interop.Word.Style style = paragraph.get_Style() as Microsoft.Office.Interop.Word.Style;
                    string styleName = style.NameLocal;
                    string text = paragraph.Range.Text;
                    if (styleName == "Title")
                        title = text.ToString();
                    else if (styleName == "Subtitle")
                        st = text.ToString() + "\n";
                    else if (styleName=="Heading 1")
                        heading1[h1c] = text.ToString()+"\n";
Bilal Amjad Microsoft Certified Professional

Similar Messages

  • How can I get only the music I want onto my iPhone using iTunes Match

    how can I get only the music I want onto my iPhone using iTunes Match?  At present it is putting a random selection on; it has none of the same control as iTunes on my Mac.  And although I uploaded all my album artwork to iCloud, it is not transferring it back to my iPhone

    Iphone are meant to be sync to one itunes library only.
    You can copy those songs to a cd and then put a copy to your itunes media library.

  • 16Gb of music...i have 2 GB space...when I sync...how can I get only the music I want...aka playlists I want...

    16Gb of music...i have 2 GB space...when I sync...how can I get only the music I want...aka playlists I want...

    You must configure to sync only the specific items you want on your iPod by enabling the necessary settings from under the iPod's Summary and Music tabs.  Perhaps this article can provide more information and assistance.
    iTunes: Syncing media content to iOS devices and iPod
    B-rock

  • How can I get iTunes to locate and play all my music files?

    How can I get iTunes to locate and play all my music files?

    I have this problem too. I am researching now. Here is what I know so far. If you right click a song then get ifo the it will say Protected AAC or purchased AAC. Protected wont play on sonos, purchased will play on sonos. It seems that all my protected were purchased 2005 to 2009 or so. I am trying to find out if apply will convert these for a small dfee or if I use the itunes cloud these tunes will convert for me. downloading and reloading is not an option for me. Pretty much a money grab by apple either way. I am sure Steve is smiling.

  • My hard drive crashed and I have lost my Itunes library. How can I get my the music that I loaded from my own CDs back on my PC from my iPod?

    My hard drived crashed in my HP Pavilion desktop and I have installed a new one. I have Windows 2007. My Itunes library is gone. How can I get all the music that I loaded onto my iPod from my own CD's back into an Itunes library?

    The loading of audio files to iPod is designed to go one way only: computer to iPod. There are some third-party applications available which will rescue an audio library and write the files back to a PC HDD. The playlists might not copy, nor the album art work, nor videos but you might be able to recover all audio files. Some apps are open source and available for free download, for example: Senuti, Onyx. There are others which are  Windows-based; do a Google search to find out. 

  • When sending e-mails, how can I show only the name and not include the e-mail address?

    When sending e-mails, how can I show only the name of the recipient and not include their full e-mail address?

    Hi beverlyfromnull,
    Have you added the recipients to your address book?

  • How can I get only the last 2 rows?

    How can I narrow down a query to get only the last two rows in a table ?
    Thanks,
    Mohan

    Thanks a lot Ram for your suggestion but already I have a query which returns a set of rows, of which I would like to further filter and get the last two rows
    <BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Ramanuj Bangad ([email protected]):
    try out something like this if it helps.
    Example:
    select * from users
    where rownum <= (select count(*) from users)
    minus
    select * from users
    where rownum <= (select count(*) -2 from users )
    <HR></BLOCKQUOTE>
    null

  • How can I save ONLY the bookmarks and extensions

    I am about to do a clean reinstall of Firefox. I want to save ONLY the Bookmarks and Extensions and NOTHING ELSE from the Firefox Profile. How can I do this please?
    Thank you,

    Both answers combined to help solve the problem. It would be good if more than one answer can be selected as "Chosen Solutions", because this situation occurs often in forums.
    Thank you to both of you!
    Kind regards.

  • HT1386 i have an old i touch. it's full and won't sync at all. how can i choose only the cd's i want from itunes on my desk top to sync into the itouch? if i just plug it in it just tells me it's full leaving my old music in place. is there a way?

    how can i (if i evan can) select only certain cd's stored in my itunes to sync into my itouch. right now i have too much music loaded into my itunes - desktop and when i try to sync my 16gb itouch it just tells me it can not sync because there is not enough space and i realize that. can i pick and choose from my desktop what i want going into my itouch?  help would be wonderful and i would need pretty detailed info for a guy like me to get it done - thanks

    With the iPod connected to the computer go to the Music pane for the iPod in iTunes and check the box that says sync only checked songs. The check the songs you want synced and click on Sync. For more info see:
    iTunes: Syncing media content to iOS devices and iPod

  • How can I get only the dual rows?

    Dear gurus,
    I want to retrieve the rows that are dual in my SQL.
    select grb.num_matricula
    from gb_ficha_financ_assistido gff,
    gb_rubricas_previdencial grp,
    gb_recebedor_beneficio grb
    where gff.cd_rubrica = grp.cd_rubrica
    and (gff.cd_fundacao = grb.cd_fundacao
    and gff.seq_recebedor = grb.seq_recebedor)
    and grp.id_rub_suplementacao = 'S'
    and gff.dt_referencia = '01/12/2004'
    group by grb.num_matricula
    The query above return 1414 rows...
    But when I execute the query below I recived 1430 rows. The only modification is the column cod_entid that was add.
    select grb.num_matricula matricula ,grb.cod_entid
    from gb_ficha_financ_assistido gff, gb_rubricas_previdencial grp,
    gb_recebedor_beneficio grb
    where gff.cd_rubrica = grp.cd_rubrica
    and (gff.cd_fundacao = grb.cd_fundacao
    and gff.seq_recebedor = grb.seq_recebedor)
    and grp.id_rub_suplementacao = 'S'
    and gff.dt_referencia = '01/12/2004'
    group by grb.num_matricula, grb.cd_empresa
    The results let me think that exists in some cases diferents cod_entid with the same num_matricula and this is wrong.
    I wanna do a SQL to recoup only the rows that has duplications.
    Is this possible?
    Regards

    You can use the following to find the duplicates:
    select num_matricula matricula, cod_entid, count(*)
    from gb_recebedor_beneficio
    group by num_matricula matricula, cod_entid
    having count(*) > 1
    However, you seem to have a mismatch in your select and group by clauses in your second query. You have grb.cod_entid in your select clause and grb.cd_empresa in your group by clause. That combination will not even run without error, so what you posted must not be what you ran to get the 1430 rows, so you might want to re-check your code carefully.

  • Something wrong with my email it keep eat up my hard drive.  how can i get into the system and delete the mail folder

    how can I delete the mail folder in the hard drive.. it keep redownload the emails and eat up my hard drive

    If you have your mail set up as an IMAP account, then it will download everything that is in your Inbox (on the online site/server) again and again. You can move your emails to another folder online after you've read them or you can also delete them online after you've saved the ones you want to keep.
    If you have your mail set up as a POP account, emails are downloaded once and then reside on your hard drive; you can indicate in Mail Preferences > Accounts if you want the messages online deleted immediately or after one week, etc.

  • How can I get rid of "History and Bookmarks" section from the search history drop down menu in safari 6.0.2?

    Let's just say I have saved bookmarks of things that i do NOT want my friends to see when they use my computer occasionally. I know they could go and find these bookmarks anyway in the bookmarks menu but they dont snoop around my computer. i would rather it not just pop up when they go to search for something or type in a webpage. If there is no way to customize what shows up in the drop down menu for search results then that is something apple overlooked. Not everybody wants things all in one place. Whats the point of deleting search history and website history if its just going to show the certain things you have bookmarked? Any solution to this would be appreciated. One solution i thought would work was disabling search from suggesting, but i guess that only supresses the webpages not the url/search bar. Oh and this is for safari 6.0.2 please dont give me outdated advice.
    Thanks

    Activate the Guest account for your friends and keep your account for yourself.

  • How can i get back the pictures and videos i deleted?

    I deleted some of my pictures and videos two months ago. now I really really need them , is there any way that I can gt them back.

    Two months ago? Highly unlikely, but you can try these;
    Data Rescue 3;
    http://www.prosofteng.com/products/data_rescue.php
    Stellar Phœnix;
    http://www.macintosh-data-recovery.com/
    Both programmes will give you a free download to scan your HD and see if the files are recoverable, but you'll have to pay for the full application to actually recover them.
    In this case I doubt there'll be much left to recover as the files will probably have been overwritten by now. If you're really desperate you could try a Forensic recovery service, but you'd be talking 4-figure cost with no guarantee of useable results.

  • How can i get all the users from weblogic server?

    how can i get all the users from weblogic server?
    i have configurated a LDAP server using iPlanet and
    in weblogic server console i see those users from LDAP
    server. but how can i get all the users in my program
    from weblogic server instead of LDAP server?
    BTW,how to configure a RDBMSAuthenticator and what should i do
    in Oracle? which tables should i create? and how are their architectures?
    Thanks
    Daniel

    BTW, i use weblogic platform 8.1
    "Daniel" <[email protected]> дÈëÓʼþ
    news:[email protected]..
    how can i get all the users from weblogic server?
    i have configurated a LDAP server using iPlanet and
    in weblogic server console i see those users from LDAP
    server. but how can i get all the users in my program
    from weblogic server instead of LDAP server?
    BTW,how to configure a RDBMSAuthenticator and what should i do
    in Oracle? which tables should i create? and how are their architectures?
    Thanks
    Daniel

  • How can I print with the black and white cartridge only?

    I am trying to print using the black and white cartridge only because magenta is out of ink but I'm getting the following error message in HP Photosmart C7200 series print dialog:
    The printer is out of ink.
    The following ink cartridges are empty: Magenta. Replace these ink cartridges to resume printing.
    How can I print with the black and white cartridge only?
    Mac OSX 10.7.3
    HP Photosmart C7280 (7200 series)
    This question was solved.
    View Solution.

    I am absolutely disgusted by this; clearly a scam from HP to make more money by selling extra ink cartridges!!  I will make sure to never buy any products from the shoddy rip off merchants at HP ever again!!
    You should be ashamed!!

Maybe you are looking for

  • Workflow Redesign

    Hi, I have to redesign my workflow . Existing Design This Workflow is for Blocked Invoices where the blocking reason can be due to price,qantity etc(some 6 reasons)  . The invoice can be blocked due to all 6 reasons also.Now my workflow is designed w

  • Deleted global colors

    We get something called Deleted global colors, it corrupts the files and consisantly copies itself when you are copy and paste from one document to another. We have also noticed that we get the virus when the deleted global colors are not in the swat

  • Excel shortcuts on Excel for Mac?

    Guys, any idea if how one can use F2 (to edit a formula) and F4 (to anchor a cell i.e. $b$3) on Excel for Mac? I cannot believe those keys cannot work or that they haven't fixed those commands onto another key...right now you just get brightness and

  • Unable to update or download anything with my Apple ID

    I am unable to update or download anything on my iTunes or App Store because it says my apple ID is invalid because I entered my password incorrectly too many times. Although I've changed my apple password multiple times since hoping it would work an

  • Java applets that worked fine under 10.6 don't work under 10.7. What can I do to correct this?

    Java applets that worked just fine are no longer working after upgrading to MacOS X 10.7 (Lion).  Here is one example:  So far, I've found two Java Applets that have become inoperative under 10.7.  Here's one example: http://www.vimas.com/videoLarge.