Consulting

Results 1 to 6 of 6

Thread: Focus Mode

  1. #1

    Focus Mode

    Recently, I came across some app with focus mode. It changes the current paragraph where the cursor is to dark font and lightens the font color of other paragraphs. So, the attention stays in that particular paragraph, which is visually arresting.

    Is it possible to create such focus mode in word?

    My work till now is to create a style with dark font and another with light font and call the light font style to all paragraphs but dark one to current paragraph. It is clumsy approach, I reckon.

    This link below gives an option to select a sentence adding color to the selection is easy. The question is about paragraph.

    http://www.vbaexpress.com/forum/show...Sentence/page2
    Last edited by Programmer_n; 10-23-2016 at 04:11 AM.

  2. #2
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    Perhaps something like this:

    'This in a stardard module:
    Option Explicit
    Dim oAppClass As New clsApp
    Public Sub AutoExec()
      Set oAppClass.oApp = Word.Application
    End Sub
    Sub AutoNew()
      Set oAppClass.oApp = Word.Application
    End Sub
    Sub AutoOpen()
      Set oAppClass.oApp = Word.Application
      ActiveDocument.Range(0, 0).Select
    End Sub
    'This in a class moduled named clsAPP
    Option Explicit
    Public WithEvents oApp As Word.Application
    Private Sub oApp_WindowSelectionChange(ByVal Sel As Selection)
       ActiveDocument.Styles("Normal").Font.ColorIndex = wdGray50
       ActiveDocument.Styles("Focus").Font.ColorIndex = wdBlack
       ActiveDocument.Range.Style = "Normal"
       Selection.Paragraphs(1).Style = "Focus"
    lbl_Exit:
      Exit Sub
    End Sub
    Last edited by gmaxey; 10-23-2016 at 07:19 AM.
    Greg

    Visit my website: http://gregmaxey.com

  3. #3
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    I think I like this better:

    Private Sub oApp_WindowSelectionChange(ByVal Sel As Selection)
       'ActiveDocument.Styles("Normal").Font.ColorIndex = wdGray50
       ActiveDocument.Range.Font.Reset
       Selection.Paragraphs(1).Range.Font.ColorIndex = wdBlack
    lbl_Exit:
      Exit Sub
    End Sub

    As long as all of your text is initially formatted using a style and the base font color is not "Auto" or "Black" then you should be able to create an effective contrast.
    Greg

    Visit my website: http://gregmaxey.com

  4. #4
    Thanks the code below works.

    Sub test()
        ActiveDocument.Styles("Normal").Font.ColorIndex = wdGray25
        ActiveDocument.Range.Font.Reset
        Selection.Paragraphs(1).Range.Font.ColorIndex = wdBlack
    lbl_Exit:
        Exit Sub
    End Sub
    What does this means?
    Sub oApp_WindowSelectionChange(ByVal Sel As Selection)

  5. #5
    Microsoft Word MVP 2003-2009 VBAX Guru gmaxey's Avatar
    Joined
    Sep 2005
    Posts
    3,340
    Location
    It is a event that fires when you change the selection from one point to another
    Greg

    Visit my website: http://gregmaxey.com

  6. #6
    Quote Originally Posted by gmaxey View Post
    It is a event that fires when you change the selection from one point to another
    Thanks
    Sub Paragraph_focus()
        ActiveDocument.Styles("Normal").Font.ColorIndex = wdGray25
        ActiveDocument.Range.Font.Reset
        Selection.Paragraphs(1).Range.Font.ColorIndex = wdBlack
    lbl_Exit:
        Exit Sub
    End Sub
    Sub Sentence_focus()
    ActiveDocument.Styles("Normal").Font.ColorIndex = wdGray25
    ActiveDocument.Range.Font.Reset
    With Selection.Sentences(1)
     .Bold = True
     .Font.ColorIndex = wdBlack
    End With
    End Sub
    Slightly amended your approach to make it work for sentence level. Even for the code above, when I put cursor pointer within the sentence and run the code, it works.

Tags for this Thread

Posting Permissions

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