Resolved Reading Word Doc - Need to get Style of the paragraph

OrangeLoon

New member
Joined
Jul 5, 2022
Messages
2
Programming Experience
1-3
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
 

JohnH

VB.NET Forum Moderator
Staff member
Joined
Dec 17, 2005
Messages
15,609
Location
Norway
Programming Experience
10+
For example compare oPara.Style.NameLocal = wdDocIn.Styles("Normal").NameLocal
Instead of the string you can also use WdBuiltinStyle.
 
Top Bottom