Results 1 to 3 of 3

Thread: Reading Word Doc via VB.Net - Need to get Style of the paragraph

  1. #1

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    2

    Reading Word Doc via VB.Net - Need to get Style of the paragraph

    Quasi-nubie here (some experience in VBA and very little in VB.Net). A rather different use-case: I am converting a VBA program into VB.Net (Microsoft Visual Studio Community 2022) and have run across a block. The program opens an existing word doc, reformats it and saves into a new document.

    I am reading the document by paragraph and I need the style (Normal, Heading 1, Heading 2, Listparagraph, etc.) of the current paragraph. As an example of the code I thought would work: if oPara.Range.Style = wdDocIn.Paragraphs.Style("Normal") then... but oPara.range.style cannot be converted into a string like it does in VBA.

    So, the question is, when reading a Word document, how do you get the style of the current paragraph.

    GSN

  2. #2
    PowerPoster jdc2000's Avatar
    Join Date
    Oct 2001
    Location
    Idaho Falls, Idaho USA
    Posts
    2,140

    Re: Reading Word Doc via VB.Net - Need to get Style of the paragraph


  3. #3

    Thread Starter
    New Member
    Join Date
    Jul 2022
    Posts
    2

    [SOLVED] Re: Reading Word Doc via VB.Net - Need to get Style of the paragraph

    Thanks!

    Dim paraStyle As Word.Style
    paraStyle = oPara.Style
    If paraStyle.NameLocal = "Normal" Then

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width