word-style

VBA in Word: Programmatically add content control with a style

半腔热情 提交于 2021-01-27 16:01:24
问题 When programatically adding a rich text content control to a Word .docm using VBA, is there a way to set a style for the contents? As a comparison, if I create a content control manually using the Word Developer toolbar, I can select "Use a style to format contents" in the properties dialog for the content control. The result I want is the same as if I did it that way, except I need to do it in code. Here's the code I have that adds the content control, it's triggered by a command button

Word style is changed after applying ApplyListTemplate

五迷三道 提交于 2020-07-07 09:13:50
问题 I have a Word document containing a numbered list like this Item 1 Item 2 Item 3 The list style is "List Paragraph". Left indent of "List Paragraph" is 0.5". If we run the following code to reapply the style "List Paragraph", the left indent of the style is now 0.75" Dim t As ListTemplate Set t = ActiveDocument.Styles("List Paragraph").ListTemplate t.ListLevels(1).ResetOnHigher = True Selection.Range.ListFormat.ApplyListTemplate t, False, wdListApplyToWholeList As a result, the list is

MS Word VBA - Finding a word and changing its style

心已入冬 提交于 2020-01-03 17:12:09
问题 I'm trying to find all instances of key words in a MS Word document and change their style. The key words are stored within an array and I want to change the style of the particular word only. Ideally this would happen as I type but that is not crucial. Attempt 1 - Based on recording a macro and changing the search term Sub Woohoo() Dim mykeywords mykeywords= Array("word1","word2","word3") For myword= LBound(mykeywords) To UBound(mykeywords) Selection.Find.ClearFormatting Selection.Find

how to assign table styles with code to a word document

一曲冷凌霜 提交于 2019-12-12 00:02:10
问题 I'm creating a word document with data from a Visual Basic 2010 software I created for my work, which consist in a report ... i was ask to generate a Microsoft word document, so now I'm creating a table and filling that table with data, something likes this oTable = oDoc.Tables.Add(oDoc.Bookmarks.Item("\endofdoc").Range, 8, 4) oTable.Range.ParagraphFormat.SpaceAfter = 6 oTable.Range.Font.Size = 10 oTable.Rows.Item(1).Range.Font.Bold = True oTable.Rows.Item(1).Range.Font.Italic = True oTable

c# comparing style objects in MS Word

佐手、 提交于 2019-12-11 05:31:52
问题 I have to edit all headings inside a word document. I tried this: Word.WdBuiltinStyle[] styleArray = { Word.WdBuiltinStyle.wdStyleHeading1, Word.WdBuiltinStyle.wdStyleHeading2, Word.WdBuiltinStyle.wdStyleHeading3, Word.WdBuiltinStyle.wdStyleHeading4, Word.WdBuiltinStyle.wdStyleHeading5, Word.WdBuiltinStyle.wdStyleHeading6, Word.WdBuiltinStyle.wdStyleHeading7, Word.WdBuiltinStyle.wdStyleHeading8, Word.WdBuiltinStyle.wdStyleHeading9 }; foreach (Word.Paragraph paragraph in Globals.ThisAddIn