Consulting

Results 1 to 2 of 2

Thread: InsertParagraph at the start of a specific color

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    VBAX Newbie
    Joined
    Sep 2017
    Posts
    4
    Location

    InsertParagraph at the start of a specific color

    (EXTREME newbie at VBA....)

    I have a specific task I perform weekly to create a PowerPoint file. Direction is sent as a word document. In the document there are notes for the presenter and the presenter includes text for PowerPoint in Red among the black text.

    I have achieved a macro that extracts the red text and converts it to the font to use for the presentation.

    The formatting gets garbled though. The end result I'd like to have is for each section of red text to be a new paragraph.

    Slides for numbered items are part of the document. There are larger batches of text that I regularly need to adjust formatting on in PowerPoint which I am perfectly fine with continuing to do. Arriving at a "list of slides" from the document sent is a big help as a first step.

    Ultimately, I'd like for this script to start a new PowerPoint file where each paragraph is a slide but I know this is a ways off....I've got plenty to learn before that!

    Because of the extreme newbie status mentioned, I'm assuming that finding the start of the color red and InsertParagraph are necessary components but I can't seem to find anything useful on how to make these ideas work together.

    Thanks in advance!

    Here's my attempt so far:

    Sub ExtractRedText()
    Dim lngColor As Long
     Application.ScreenUpdating = False
     lngColor = Selection.Range.HighlightColorIndex = wdBlack
     With ActiveDocument.Range(0, 0)
       With .Find
         .ClearFormatting
         .Replacement.ClearFormatting
         .Text = ""
         .Replacement.Text = ""
         .Forward = True
         .Wrap = wdFindContinue
         .Format = True
         .Font.Color = lngColor
         .MatchCase = False
         .MatchWholeWord = False
         .MatchWildcards = False
         .MatchSoundsLike = False
         .MatchAllWordForms = False
         .Execute Replace:=wdReplaceAll
                Selection.WholeStory
                Selection.Font.Name = "Bebas Neue Regular"
                Selection.Font.Size = 18
                Selection.Font.TextColor = RGB(0, 0, 0)
            
       End With
     End With
     'UpdateFont = Selection.Range.HighlightColorIndex = wdRed
    
     'Application.ScreenUpdating = True
     End Sub
    Last edited by VABP; 10-28-2018 at 11:13 AM.

Posting Permissions

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